mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-06-16 21:03:58 +08:00
fix(providers): fetch recent requests on mount
The new workbench only wired refreshRecentRequests into the manual refresh button; the hook itself just set an interval (240s). As a result the status bar showed empty/zero until the first poll. Load on mount when enabled (cache hit avoids a network round-trip).
This commit is contained in:
@@ -110,8 +110,12 @@ export function useProviderRecentRequests(options: UseProviderRecentRequestsOpti
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setUsageByProvider(enabled ? cachedUsageByProvider : EMPTY_USAGE_BY_PROVIDER);
|
||||
}, [enabled]);
|
||||
if (!enabled) {
|
||||
setUsageByProvider(EMPTY_USAGE_BY_PROVIDER);
|
||||
return;
|
||||
}
|
||||
void loadRecentRequests().catch(() => {});
|
||||
}, [enabled, loadRecentRequests]);
|
||||
|
||||
useInterval(() => {
|
||||
void refreshRecentRequests().catch(() => {});
|
||||
|
||||
Reference in New Issue
Block a user