enhance(frontend): 非同期的なコンポーネントの読み込み時のハンドリングを強化

This commit is contained in:
syuilo 2025-06-02 08:43:04 +09:00
parent 8f025c447b
commit d40c083233
1 changed files with 7 additions and 2 deletions

View File

@ -211,13 +211,17 @@ export async function popupAsyncWithDialog<T extends Component>(
props: ComponentProps<T>, props: ComponentProps<T>,
events: Partial<ComponentEmit<T>> = {}, events: Partial<ComponentEmit<T>> = {},
): Promise<{ dispose: () => void }> { ): Promise<{ dispose: () => void }> {
const closeWaiting = waiting();
let component: T; let component: T;
let closeWaiting = () => {};
const timer = window.setTimeout(() => {
closeWaiting = waiting();
}, 100); // コンポーネントがキャッシュされている場合にもwaitingが表示されて画面がちらつくのを防止するためにラグを追加
try { try {
component = await componentFetching; component = await componentFetching;
} catch (err) { } catch (err) {
window.clearTimeout(timer);
closeWaiting(); closeWaiting();
alert({ alert({
type: 'error', type: 'error',
@ -227,6 +231,7 @@ export async function popupAsyncWithDialog<T extends Component>(
throw err; throw err;
} }
window.clearTimeout(timer);
closeWaiting(); closeWaiting();
markRaw(component); markRaw(component);