Skip to content

Commit 9ed078d

Browse files
authored
Wait max for 1s for config to load before init
1 parent 2560512 commit 9ed078d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

resources/js/package.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
window.debug = import.meta.env.VITE_DEBUG == 'true'
22
window.Notify = (message, type = 'info', params = [], link = null) =>
3-
setTimeout(() => window.$emit('notification-message', message, type, params, link))
3+
setTimeout(() => window.$emit('notification-message', message, type, params, link), window.app ? 0 : 500)
44

55
if (!window.process) {
66
// Workaround for process missing, if data is actually needed from here you should apply the following polyfill.
@@ -49,11 +49,18 @@ if (import.meta.env.VITE_DEBUG === 'true') {
4949

5050
let booting = false
5151
let rootEl = null
52-
function init() {
52+
async function init() {
5353
if (booting || (rootEl && document.body.contains(rootEl))) {
5454
return
5555
}
5656
booting = true
57+
for(let i = 0; i < 20; i++) {
58+
// Wait until config is available, for a max of 1s
59+
if (window.config.store) {
60+
break;
61+
}
62+
await new Promise((resolve) => setTimeout(resolve, 50));
63+
}
5764
rootEl = document.querySelector('#app')
5865

5966
// Check if the localstorage needs a flush.

0 commit comments

Comments
 (0)