Add live account appeal updates and restricted status settings

This commit is contained in:
2026-10-13 14:22:12 +05:00
parent cfe5820802
commit 8c3de302e7
21 changed files with 508 additions and 52 deletions

34
lib/realtime-refresh.ts Normal file
View File

@@ -0,0 +1,34 @@
/** Serialize refreshes, retaining one follow-up if a change arrives mid-request. */
export function realtimeRefresh(
refresh: () => Promise<void>,
onError: (error: unknown) => void,
) {
let running = false;
let pending = false;
let closed = false;
async function request() {
if (closed) return;
pending = true;
if (running) return;
running = true;
try {
while (pending && !closed) {
pending = false;
try {
await refresh();
} catch (error) {
if (!closed) onError(error);
}
}
} finally {
running = false;
}
}
return {
request,
close: () => {
closed = true;
pending = false;
},
};
}