mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-01 20:55:16 +09:00
Overlay click and Escape closed the setup modal and dropped the user onto the Change password form. Add a Modal closeOnDismiss prop (default unchanged) and use it for the setup modal; Cancel and the header X still close it. Guard Enable with a ref-based single-flight lock in both the settings tab and the setup wizard so a double-click cannot fire two requests, and show a hint after a failed confirm that the code may belong to an older QR. Add the string to every locale.
16 lines
463 B
JavaScript
16 lines
463 B
JavaScript
// Drops a call while a previous one is still running. Backed by a plain
|
|
// object (hold it in a useRef) so a double-click is refused synchronously,
|
|
// before React has flushed any `disabled` state.
|
|
export function createSingleFlight() {
|
|
let busy = false;
|
|
return async function run(fn) {
|
|
if (busy) return undefined;
|
|
busy = true;
|
|
try {
|
|
return await fn();
|
|
} finally {
|
|
busy = false;
|
|
}
|
|
};
|
|
}
|