summaryrefslogtreecommitdiff
path: root/src/client/os.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-10-18 10:11:34 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-10-18 10:11:34 +0900
commit1df7abfbb906f2e364b5eb5fefc5f9de5dd60026 (patch)
tree0a72f1f7a559d04e1fc77bfde69c07b23fa47363 /src/client/os.ts
parentActivityPubでリモートのオブジェクトをGETするときのリクエ... (diff)
downloadmisskey-1df7abfbb906f2e364b5eb5fefc5f9de5dd60026.tar.gz
misskey-1df7abfbb906f2e364b5eb5fefc5f9de5dd60026.tar.bz2
misskey-1df7abfbb906f2e364b5eb5fefc5f9de5dd60026.zip
Improve waiting dialog
Diffstat (limited to 'src/client/os.ts')
-rw-r--r--src/client/os.ts40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/client/os.ts b/src/client/os.ts
index 03bae65539..688bc136df 100644
--- a/src/client/os.ts
+++ b/src/client/os.ts
@@ -62,17 +62,34 @@ export function api(endpoint: string, data: Record<string, any> = {}, token?: st
return promise;
}
-export function apiWithDialog(endpoint: string, data: Record<string, any> = {}, token?: string | null | undefined, onSuccess?: (res: any) => void, onFailure?: (e: Error) => void) {
+export function apiWithDialog(
+ endpoint: string,
+ data: Record<string, any> = {},
+ token?: string | null | undefined,
+ onSuccess?: (res: any) => void,
+ onFailure?: (e: Error) => void,
+) {
+ const promise = api(endpoint, data, token);
+ promiseDialog(promise, onSuccess, onFailure);
+
+ return promise;
+}
+
+export function promiseDialog<T extends Promise<any>>(
+ promise: T,
+ onSuccess?: (res: any) => void,
+ onFailure?: (e: Error) => void,
+ text?: string,
+): T {
const showing = ref(true);
- const state = ref('waiting');
+ const success = ref(false);
- const promise = api(endpoint, data, token);
promise.then(res => {
if (onSuccess) {
showing.value = false;
onSuccess(res);
} else {
- state.value = 'success';
+ success.value = true;
setTimeout(() => {
showing.value = false;
}, 1000);
@@ -89,9 +106,10 @@ export function apiWithDialog(endpoint: string, data: Record<string, any> = {},
}
});
- popup(defineAsyncComponent(() => import('@/components/icon-dialog.vue')), {
- type: state,
- showing: showing
+ popup(defineAsyncComponent(() => import('@/components/waiting-dialog.vue')), {
+ success: success,
+ showing: showing,
+ text: text,
}, {}, 'closed');
return promise;
@@ -161,8 +179,8 @@ export function success() {
setTimeout(() => {
showing.value = false;
}, 1000);
- popup(defineAsyncComponent(() => import('@/components/icon-dialog.vue')), {
- type: 'success',
+ popup(defineAsyncComponent(() => import('@/components/waiting-dialog.vue')), {
+ success: true,
showing: showing
}, {
done: () => resolve(),
@@ -173,8 +191,8 @@ export function success() {
export function waiting() {
return new Promise((resolve, reject) => {
const showing = ref(true);
- popup(defineAsyncComponent(() => import('@/components/icon-dialog.vue')), {
- type: 'waiting',
+ popup(defineAsyncComponent(() => import('@/components/waiting-dialog.vue')), {
+ success: false,
showing: showing
}, {
done: () => resolve(),