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