feat: prevent refreshing when setting passcode
This commit is contained in:
@@ -135,3 +135,16 @@ if (!Array.prototype.includes) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function preventRefreshing(
|
||||
message: string,
|
||||
operation: () => Promise<void> | void
|
||||
) {
|
||||
const onBeforeUnload = window.onbeforeunload;
|
||||
try {
|
||||
window.onbeforeunload = () => message;
|
||||
await operation();
|
||||
} finally {
|
||||
window.onbeforeunload = onBeforeUnload;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user