fix(settings): show excluding state on library index exclude action

Flush UI before the async unbind, disable repeat clicks, cancel an active
sync when needed, and label the button "Excluding…" / localized equivalent.
This commit is contained in:
Maxim Isaev
2026-05-22 14:14:09 +03:00
parent 23f7ba02d6
commit 60aad12cd4
12 changed files with 68 additions and 8 deletions
+19
View File
@@ -62,6 +62,25 @@ function waitForServerIdle(serverId: string): Promise<void> {
});
}
/** Wait until a server emits `library:sync-idle`, or time out (best-effort). */
export function waitForLibrarySyncIdle(serverId: string, timeoutMs = 15_000): Promise<void> {
return new Promise(resolve => {
let unlisten: (() => void) | undefined;
const timer = setTimeout(() => {
unlisten?.();
resolve();
}, timeoutMs);
void subscribeLibrarySyncIdle(p => {
if (p.serverId !== serverId) return;
clearTimeout(timer);
unlisten?.();
resolve();
}).then(fn => {
unlisten = fn;
});
});
}
async function invokeSync(serverId: string, kind: LibrarySyncQueueKind): Promise<void> {
if (kind === 'verify') {
await librarySyncVerifyIntegrity({ serverId });