working() should be a singleton

Massimo Melina committed Dec 30, 2021 at 12:34 UTC 9e2734797638adc6fe2f79bde1b68623ab50bfc4
1 file changed +7
frontend/src/misc.ts
+7
@@ -58,11 +58,18 @@ export function waitFor<T>(cb:()=>T, ms:number=200) : Promise<Exclude<T,Falsy>>
58 })
59 }
60
61 +let isWorking = false // we want the 'working' thing to be singleton
62 export function working() {
63 + if (isWorking)
64 + return ()=>{} // noop
65 + isWorking = true
66 return newDialog({
67 closable: false,
68 content: Spinner,
69 reserveClosing: true,
70 className: 'working',
71 + onClose(){
72 + isWorking = false
73 + }
74 })
75 }