Skip to content

Commit 56944f8

Browse files
committed
backupAndRestore: Possible restore-from-file fix for certain environments
`requestIdleCallbacks` gives the browser a little more time to retrieve data from the file selector window after it is closed.
1 parent 780c772 commit 56944f8

File tree

1 file changed

+2
-2
lines changed
  • lib/modules/backupAndRestore/providers

1 file changed

+2
-2
lines changed

lib/modules/backupAndRestore/providers/File.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class File extends Provider {
2525
reader.readAsText(file);
2626
});
2727
// There is no proper way to detect when a file dialog is closed.
28-
// We must use setTimeout so that the change event fires first.
29-
Promise.all([waitForEvent(window, 'mousemove'), waitForEvent(window, 'focus')]).then(() => setTimeout(() => {
28+
// We must use requestIdleCallback so that the change event has time to fire first.
29+
Promise.all([waitForEvent(window, 'mousemove'), waitForEvent(window, 'focus')]).then(() => requestIdleCallback(() => {
3030
if (loading) return; // Reader has started loading
3131
if (!link.files.length) reject(new Error('No file selected.'));
3232
}));

0 commit comments

Comments
 (0)