Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ export default class BrowserEventsFunctionsExtensionOpener {
adhocInput.type = 'file';
adhocInput.multiple = true;
adhocInput.accept = 'application/json,.json';
adhocInput.style.display = 'none';

const removeInput = () => {
const body = document.body;
if (body && body.contains(adhocInput)) {
body.removeChild(adhocInput);
}
};

adhocInput.onchange = e => {
return resolve(e.target.files);
removeInput();
return resolve(Array.from(e.target.files));
};

// There is no built-in way to know if the user closed the file picking dialog
Expand All @@ -58,12 +68,14 @@ export default class BrowserEventsFunctionsExtensionOpener {
onFilePickingDialogFinishedClosing
);
}
removeInput();
if (!adhocInput.files.length) {
resolve([]);
}
};

window.addEventListener('focus', onFocusBackWindow);
if (document.body) document.body.appendChild(adhocInput);
adhocInput.click();
}
});
Expand Down Expand Up @@ -118,7 +130,17 @@ export default class BrowserEventsFunctionsExtensionOpener {
adhocInput.type = 'file';
adhocInput.multiple = false;
adhocInput.accept = 'application/gdo,.gdo';
adhocInput.style.display = 'none';

const removeInput = () => {
const body = document.body;
if (body && body.contains(adhocInput)) {
body.removeChild(adhocInput);
}
};

adhocInput.onchange = e => {
removeInput();
return resolve(e.target.files[0]);
};

Expand Down Expand Up @@ -146,12 +168,14 @@ export default class BrowserEventsFunctionsExtensionOpener {
onFilePickingDialogFinishedClosing
);
}
removeInput();
if (!adhocInput.files.length) {
resolve('');
}
};

window.addEventListener('focus', onFocusBackWindow);
if (document.body) document.body.appendChild(adhocInput);
adhocInput.click();
}
});
Expand Down
11 changes: 8 additions & 3 deletions newIDE/app/src/ServiceWorkerSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ export function registerServiceWorker() {
console.error('Error during service worker registration:', error);
});

serviceWorker.ready.then(registration => {
if (!isDev) {
// Forces a check right now for a newer service worker script.
// If there is one, it will be installed (see the service worker script to verify how in development
// a new service worker script does a `self.skipWaiting()` and `self.clients.claim()`).
registration.update();
});
// In development, the Date.now() cache-buster in the SW URL already ensures a fresh
// script on every load — calling update() on top of it causes a Firefox error because
// the ready registration's scriptURL no longer matches the newly registered URL.
serviceWorker.ready.then(registration => {
registration.update();
});
}
});
}
Loading