mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-03-21 03:30:42 +00:00
enhance(frontend): 非同期的なコンポーネントの読み込み時のハンドリングを強化
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user