fix dashboard shit
This commit is contained in:
@@ -18,6 +18,7 @@ export async function loadWithOptions(options = {}) {
|
|||||||
const { force = false, reorder = false } = options;
|
const { force = false, reorder = false } = options;
|
||||||
if (state.isLoading) {
|
if (state.isLoading) {
|
||||||
state.pendingForce = state.pendingForce || force;
|
state.pendingForce = state.pendingForce || force;
|
||||||
|
state.pendingReorder = state.pendingReorder || reorder;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.isLoading = true;
|
state.isLoading = true;
|
||||||
@@ -52,10 +53,12 @@ export async function loadWithOptions(options = {}) {
|
|||||||
console.error("load clients", err);
|
console.error("load clients", err);
|
||||||
} finally {
|
} finally {
|
||||||
state.isLoading = false;
|
state.isLoading = false;
|
||||||
if (state.pendingForce) {
|
if (state.pendingForce || state.pendingReorder) {
|
||||||
const shouldForce = state.pendingForce;
|
const shouldForce = state.pendingForce;
|
||||||
|
const shouldReorder = state.pendingReorder;
|
||||||
state.pendingForce = false;
|
state.pendingForce = false;
|
||||||
loadWithOptions({ force: shouldForce });
|
state.pendingReorder = false;
|
||||||
|
loadWithOptions({ force: shouldForce, reorder: shouldReorder });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +128,7 @@ function connectDashboardWs() {
|
|||||||
try {
|
try {
|
||||||
const msg = typeof event.data === "string" ? JSON.parse(event.data) : null;
|
const msg = typeof event.data === "string" ? JSON.parse(event.data) : null;
|
||||||
if (msg && msg.type === "clients_changed") {
|
if (msg && msg.type === "clients_changed") {
|
||||||
loadWithOptions({ force: false });
|
loadWithOptions({ force: false, reorder: true });
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
};
|
};
|
||||||
@@ -157,7 +160,7 @@ function adjustPollingForWs() {
|
|||||||
? FALLBACK_POLL_MS
|
? FALLBACK_POLL_MS
|
||||||
: getConfiguredPollIntervalMs(POLL_INTERVAL_MS);
|
: getConfiguredPollIntervalMs(POLL_INTERVAL_MS);
|
||||||
pollTimer = setInterval(() => {
|
pollTimer = setInterval(() => {
|
||||||
loadWithOptions({ force: false });
|
loadWithOptions({ force: false, reorder: true });
|
||||||
}, interval);
|
}, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +171,7 @@ export function startAutoRefresh(intervalMs = POLL_INTERVAL_MS) {
|
|||||||
: getConfiguredPollIntervalMs(intervalMs);
|
: getConfiguredPollIntervalMs(intervalMs);
|
||||||
clearInterval(pollTimer);
|
clearInterval(pollTimer);
|
||||||
pollTimer = setInterval(() => {
|
pollTimer = setInterval(() => {
|
||||||
loadWithOptions({ force: false });
|
loadWithOptions({ force: false, reorder: true });
|
||||||
}, effectiveInterval);
|
}, effectiveInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,6 @@ export const state = {
|
|||||||
lastDigest: "",
|
lastDigest: "",
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
pendingForce: false,
|
pendingForce: false,
|
||||||
|
pendingReorder: false,
|
||||||
thumbnailsRequested: false,
|
thumbnailsRequested: false,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user