Add live account appeal updates and restricted status settings
This commit is contained in:
@@ -21,7 +21,7 @@ export async function accountProfile(account: User) {
|
||||
await admin()
|
||||
.from("profiles")
|
||||
.select(
|
||||
"id,display_name,role,name_glow,glow_color,bug_finder,custom_prefix,custom_prefix_icon",
|
||||
"id,display_name,role,name_glow,glow_color,bug_finder,custom_prefix,custom_prefix_icon,account_status,account_reason,account_changed_at",
|
||||
)
|
||||
.eq("id", account.id)
|
||||
.single(),
|
||||
|
||||
34
lib/realtime-refresh.ts
Normal file
34
lib/realtime-refresh.ts
Normal 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;
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user