From 1df7abfbb906f2e364b5eb5fefc5f9de5dd60026 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 18 Oct 2020 10:11:34 +0900 Subject: Improve waiting dialog --- src/client/scripts/search.ts | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'src/client/scripts') diff --git a/src/client/scripts/search.ts b/src/client/scripts/search.ts index fbdc32dfb1..540aba2a92 100644 --- a/src/client/scripts/search.ts +++ b/src/client/scripts/search.ts @@ -48,29 +48,18 @@ export async function search(q?: string | null | undefined) { } if (q.startsWith('https://')) { - /* - const dialog = os.dialog({ - type: 'waiting', - text: i18n.global.t('fetchingAsApObject') + '...', - showOkButton: false, - showCancelButton: false, - cancelableByBgClick: false + const promise = os.api('ap/show', { + uri: q }); - */ - try { - const res = await os.api('ap/show', { - uri: q - }); - //dialog.cancel(); - if (res.type === 'User') { - router.push(`/@${res.object.username}@${res.object.host}`); - } else if (res.type === 'Note') { - router.push(`/notes/${res.object.id}`); - } - } catch (e) { - //dialog.cancel(); - // TODO: Show error + os.promiseDialog(promise, null, null, i18n.global.t('fetchingAsApObject')); + + const res = await promise; + + if (res.type === 'User') { + router.push(`/@${res.object.username}@${res.object.host}`); + } else if (res.type === 'Note') { + router.push(`/notes/${res.object.id}`); } return; -- cgit v1.2.3-freya