tycono 0.1.107-beta.1 → 0.1.107-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/tui/hooks/useApi.ts +17 -10
package/package.json
CHANGED
package/src/tui/hooks/useApi.ts
CHANGED
|
@@ -59,13 +59,22 @@ export function useApi(): ApiState {
|
|
|
59
59
|
|
|
60
60
|
const refresh = useCallback(async () => {
|
|
61
61
|
try {
|
|
62
|
-
const
|
|
62
|
+
const promises: [
|
|
63
|
+
Promise<CompanyInfo | null>,
|
|
64
|
+
Promise<SessionInfo[]>,
|
|
65
|
+
Promise<ExecStatus | null>,
|
|
66
|
+
Promise<{ waves: Array<{ waveId: string; sessionIds: string[] }> }>,
|
|
67
|
+
Promise<{ sessions: ActiveSessionInfo[]; summary: { active: number; totalPorts: number } }>,
|
|
68
|
+
Promise<PastWaveInfo[]>,
|
|
69
|
+
] = [
|
|
63
70
|
fetchCompany().catch(() => null),
|
|
64
71
|
fetchSessions().catch(() => []),
|
|
65
72
|
fetchExecStatus().catch(() => null),
|
|
66
73
|
fetchActiveWaves().catch(() => ({ waves: [] })),
|
|
67
74
|
fetchActiveSessions().catch(() => ({ sessions: [], summary: { active: 0, totalPorts: 0 } })),
|
|
68
|
-
|
|
75
|
+
!pastWavesLoadedRef.current ? fetchPastWaves(20).catch(() => []) : Promise.resolve([]),
|
|
76
|
+
];
|
|
77
|
+
const [comp, sess, exec, waves, activeSess, pastWavesResult] = await Promise.all(promises);
|
|
69
78
|
|
|
70
79
|
if (!mountedRef.current) return;
|
|
71
80
|
|
|
@@ -85,6 +94,12 @@ export function useApi(): ApiState {
|
|
|
85
94
|
setActiveSessions(activeSess.sessions ?? []);
|
|
86
95
|
setPortSummary(activeSess.summary ?? { active: 0, totalPorts: 0 });
|
|
87
96
|
|
|
97
|
+
// Past waves (load once, included in Promise.all)
|
|
98
|
+
if (!pastWavesLoadedRef.current && pastWavesResult.length > 0) {
|
|
99
|
+
pastWavesLoadedRef.current = true;
|
|
100
|
+
setPastWaves(pastWavesResult);
|
|
101
|
+
}
|
|
102
|
+
|
|
88
103
|
// KB docs (load once, not every poll)
|
|
89
104
|
if (!kbLoadedRef.current) {
|
|
90
105
|
kbLoadedRef.current = true;
|
|
@@ -93,14 +108,6 @@ export function useApi(): ApiState {
|
|
|
93
108
|
}).catch(() => {});
|
|
94
109
|
}
|
|
95
110
|
|
|
96
|
-
// Past waves (load once)
|
|
97
|
-
if (!pastWavesLoadedRef.current) {
|
|
98
|
-
pastWavesLoadedRef.current = true;
|
|
99
|
-
fetchPastWaves(20).then(pw => {
|
|
100
|
-
if (mountedRef.current) setPastWaves(pw);
|
|
101
|
-
}).catch(() => {});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
111
|
setError(null);
|
|
105
112
|
setLoaded(true);
|
|
106
113
|
} catch (err) {
|