diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2020-10-18 10:11:34 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2020-10-18 10:11:34 +0900 |
| commit | 1df7abfbb906f2e364b5eb5fefc5f9de5dd60026 (patch) | |
| tree | 0a72f1f7a559d04e1fc77bfde69c07b23fa47363 /src/client/pages | |
| parent | ActivityPubでリモートのオブジェクトをGETするときのリクエ... (diff) | |
| download | sharkey-1df7abfbb906f2e364b5eb5fefc5f9de5dd60026.tar.gz sharkey-1df7abfbb906f2e364b5eb5fefc5f9de5dd60026.tar.bz2 sharkey-1df7abfbb906f2e364b5eb5fefc5f9de5dd60026.zip | |
Improve waiting dialog
Diffstat (limited to 'src/client/pages')
| -rw-r--r-- | src/client/pages/follow.vue | 52 | ||||
| -rw-r--r-- | src/client/pages/instance/emojis.vue | 19 | ||||
| -rw-r--r-- | src/client/pages/settings/import-export.vue | 20 | ||||
| -rw-r--r-- | src/client/pages/test.vue | 15 |
4 files changed, 31 insertions, 75 deletions
diff --git a/src/client/pages/follow.vue b/src/client/pages/follow.vue index 13e0a62a0d..b1ab7f9f6b 100644 --- a/src/client/pages/follow.vue +++ b/src/client/pages/follow.vue @@ -6,26 +6,20 @@ <script lang="ts"> import { defineComponent } from 'vue'; import * as os from '@/os'; +import parseAcct from '../../misc/acct/parse'; export default defineComponent({ created() { const acct = new URL(location.href).searchParams.get('acct'); if (acct == null) return; - /* - const dialog = os.dialog({ - type: 'waiting', - text: this.$t('fetchingAsApObject') + '...', - showOkButton: false, - showCancelButton: false, - cancelableByBgClick: false - }); - */ + let promise; if (acct.startsWith('https://')) { - os.api('ap/show', { + promise = os.api('ap/show', { uri: acct - }).then(res => { + }); + promise.then(res => { if (res.type == 'User') { this.follow(res.object); } else if (res.type === 'Note') { @@ -38,30 +32,15 @@ export default defineComponent({ window.close(); }); } - }).catch(e => { - os.dialog({ - type: 'error', - text: e - }).then(() => { - window.close(); - }); - }).finally(() => { - //dialog.close(); }); } else { - os.api('users/show', parseAcct(acct)).then(user => { + promise = os.api('users/show', parseAcct(acct)); + promise.then(user => { this.follow(user); - }).catch(e => { - os.dialog({ - type: 'error', - text: e - }).then(() => { - window.close(); - }); - }).finally(() => { - //dialog.close(); }); } + + os.promiseDialog(promise, null, null, this.$t('fetchingAsApObject')); }, methods: { @@ -77,19 +56,8 @@ export default defineComponent({ return; } - os.api('following/create', { + os.apiWithDialog('following/create', { userId: user.id - }).then(() => { - os.success().then(() => { - window.close(); - }); - }).catch(e => { - os.dialog({ - type: 'error', - text: e - }).then(() => { - window.close(); - }); }); } } diff --git a/src/client/pages/instance/emojis.vue b/src/client/pages/instance/emojis.vue index 465a9ebe00..b254b65765 100644 --- a/src/client/pages/instance/emojis.vue +++ b/src/client/pages/instance/emojis.vue @@ -106,24 +106,13 @@ export default defineComponent({ async add(e) { const files = await selectFile(e.currentTarget || e.target, null, true); - const dialog = os.dialog({ - type: 'waiting', - text: this.$t('doing') + '...', - showOkButton: false, - showCancelButton: false, - cancelableByBgClick: false - }); - - Promise.all(files.map(file => os.api('admin/emoji/add', { + const promise = Promise.all(files.map(file => os.api('admin/emoji/add', { fileId: file.id, - }))) - .then(() => { + }))); + promise.then(() => { this.$refs.emojis.reload(); - os.success(); - }) - .finally(() => { - dialog.cancel(); }); + os.promiseDialog(promise); }, async edit(emoji) { diff --git a/src/client/pages/settings/import-export.vue b/src/client/pages/settings/import-export.vue index a5a0085277..8943695dfd 100644 --- a/src/client/pages/settings/import-export.vue +++ b/src/client/pages/settings/import-export.vue @@ -69,31 +69,15 @@ export default defineComponent({ data.append('file', file); data.append('i', this.$store.state.i.token); - const dialog = os.dialog({ - type: 'waiting', - text: this.$t('uploading') + '...', - showOkButton: false, - showCancelButton: false, - cancelableByBgClick: false - }); - - fetch(apiUrl + '/drive/files/create', { + const promise = fetch(apiUrl + '/drive/files/create', { method: 'POST', body: data }) .then(response => response.json()) .then(f => { this.reqImport(f); - }) - .catch(e => { - os.dialog({ - type: 'error', - text: e - }); - }) - .finally(() => { - dialog.close(); }); + os.promiseDialog(promise); }, reqImport(file) { diff --git a/src/client/pages/test.vue b/src/client/pages/test.vue index 02b4d1614d..b053b859bb 100644 --- a/src/client/pages/test.vue +++ b/src/client/pages/test.vue @@ -107,6 +107,14 @@ </div> <div class="_card _vMargin"> + <div class="_title">Waiting dialog</div> + <div class="_content"> + <MkButton inline @click="openWaitingDialog()">icon only</MkButton> + <MkButton inline @click="openWaitingDialog('Doing')">with text</MkButton> + </div> + </div> + + <div class="_card _vMargin"> <div class="_title">Messaging window</div> <div class="_content"> <MkButton @click="messagingWindowOpen()">open</MkButton> @@ -224,6 +232,13 @@ export default defineComponent({ os.pageWindow('/my/messaging', defineAsyncComponent(() => import('@/pages/messaging/index.vue'))); }, + openWaitingDialog(text?) { + const promise = new Promise((resolve, reject) => { + setTimeout(resolve, 2000); + }); + os.promiseDialog(promise, null, null, text); + }, + resetTutorial() { this.$store.dispatch('settings/set', { key: 'tutorial', value: 0 }); }, |