diff --git a/packages/frontend/src/pizzax.ts b/packages/frontend/src/pizzax.ts index 642e1f4f7f2cd29649bdf82d03f2f55b5ef7803b..7ff09f75fbefbaa7ac92697d88da0c157335434c 100644 --- a/packages/frontend/src/pizzax.ts +++ b/packages/frontend/src/pizzax.ts @@ -23,8 +23,13 @@ export class Storage<T extends StateDef> { // TODO: ã“ã‚ŒãŒå®Ÿè£…ã•ã‚ŒãŸã‚‰readonlyã«ã—ãŸã„: https://github.com/microsoft/TypeScript/issues/37487 public readonly state: { [K in keyof T]: T[K]['default'] }; public readonly reactiveState: { [K in keyof T]: Ref<T[K]['default']> }; + public readonly ready: Promise<void>; + private markAsReady: () => void = () => {}; constructor(key: string, def: T) { + this.ready = new Promise((res) => { + this.markAsReady = res; + }); this.key = key; this.keyForLocalStorage = 'pizzax::' + key; this.def = def; @@ -72,6 +77,7 @@ export class Storage<T extends StateDef> { } } localStorage.setItem(this.keyForLocalStorage + '::cache::' + $i.id, JSON.stringify(cache)); + this.markAsReady(); }); }, 1); // streamingã®user storage updateイベントを監視ã—ã¦æ›´æ–° @@ -87,6 +93,8 @@ export class Storage<T extends StateDef> { localStorage.setItem(this.keyForLocalStorage + '::cache::' + $i.id, JSON.stringify(cache)); } }); + } else { + this.markAsReady(); } } diff --git a/packages/frontend/src/ui/classic.vue b/packages/frontend/src/ui/classic.vue index 532829ee2e108e0fc455d3cdfb4556ca87978770..6369bb897605aa7b82f3221ec91b7f64bb90c8ac 100644 --- a/packages/frontend/src/ui/classic.vue +++ b/packages/frontend/src/ui/classic.vue @@ -7,7 +7,7 @@ <XSidebar/> </div> <div v-else ref="widgetsLeft" class="widgets left"> - <XWidgets place="left" @mounted="attachSticky(widgetsLeft)" :classic="true"/> + <XWidgets place="left" :classic="true" @mounted="attachSticky(widgetsLeft)"/> </div> <main class="main" :style="{ background: pageMetadata?.value?.bg }" @contextmenu.stop="onContextmenu"> @@ -17,7 +17,7 @@ </main> <div v-if="isDesktop" ref="widgetsRight" class="widgets right"> - <XWidgets :place="showMenuOnTop ? 'right' : null" @mounted="attachSticky(widgetsRight)" :classic="true"/> + <XWidgets :place="showMenuOnTop ? 'right' : null" :classic="true" @mounted="attachSticky(widgetsRight)"/> </div> </div> @@ -129,18 +129,20 @@ if (window.innerWidth < 1024) { document.documentElement.style.overflowY = 'scroll'; -if (defaultStore.state.widgets.length === 0) { - defaultStore.set('widgets', [{ - name: 'calendar', - id: 'a', place: null, data: {}, - }, { - name: 'notifications', - id: 'b', place: null, data: {}, - }, { - name: 'trends', - id: 'c', place: null, data: {}, - }]); -} +defaultStore.ready.then(() => { + if (defaultStore.state.widgets.length === 0) { + defaultStore.set('widgets', [{ + name: 'calendar', + id: 'a', place: null, data: {}, + }, { + name: 'notifications', + id: 'b', place: null, data: {}, + }, { + name: 'trends', + id: 'c', place: null, data: {}, + }]); + } +}); onMounted(() => { window.addEventListener('resize', () => { diff --git a/packages/frontend/src/ui/universal.vue b/packages/frontend/src/ui/universal.vue index 0d235ac205415e964e94d175c0cad7470de65b5a..865616f19221f24ef0f96bbb4afb4264d800dbb1 100644 --- a/packages/frontend/src/ui/universal.vue +++ b/packages/frontend/src/ui/universal.vue @@ -113,18 +113,20 @@ mainRouter.on('change', () => { document.documentElement.style.overflowY = 'scroll'; -if (defaultStore.state.widgets.length === 0) { - defaultStore.set('widgets', [{ - name: 'calendar', - id: 'a', place: 'right', data: {}, - }, { - name: 'notifications', - id: 'b', place: 'right', data: {}, - }, { - name: 'trends', - id: 'c', place: 'right', data: {}, - }]); -} +defaultStore.ready.then(() => { + if (defaultStore.state.widgets.length === 0) { + defaultStore.set('widgets', [{ + name: 'calendar', + id: 'a', place: 'right', data: {}, + }, { + name: 'notifications', + id: 'b', place: 'right', data: {}, + }, { + name: 'trends', + id: 'c', place: 'right', data: {}, + }]); + } +}); onMounted(() => { if (!isDesktop.value) {