mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
allow os.promiseDialog to accept a callback
This commit is contained in:
parent
fadf39d8e7
commit
5b8764d6df
1 changed files with 5 additions and 1 deletions
|
@ -101,7 +101,7 @@ export const apiWithDialog = (<
|
||||||
});
|
});
|
||||||
|
|
||||||
export function promiseDialog<T extends Promise<any>>(
|
export function promiseDialog<T extends Promise<any>>(
|
||||||
promise: T,
|
promise: T | (() => T),
|
||||||
onSuccess?: ((res: Awaited<T>) => void) | null,
|
onSuccess?: ((res: Awaited<T>) => void) | null,
|
||||||
onFailure?: ((err: Misskey.api.APIError) => void) | null,
|
onFailure?: ((err: Misskey.api.APIError) => void) | null,
|
||||||
text?: string,
|
text?: string,
|
||||||
|
@ -109,6 +109,10 @@ export function promiseDialog<T extends Promise<any>>(
|
||||||
const showing = ref(true);
|
const showing = ref(true);
|
||||||
const success = ref(false);
|
const success = ref(false);
|
||||||
|
|
||||||
|
if (typeof(promise) === 'function') {
|
||||||
|
promise = promise();
|
||||||
|
}
|
||||||
|
|
||||||
promise.then(res => {
|
promise.then(res => {
|
||||||
if (onSuccess) {
|
if (onSuccess) {
|
||||||
showing.value = false;
|
showing.value = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue