diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-11-18 18:45:58 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-11-18 18:45:58 +0900 |
| commit | ea9aeef9d8790db51c59a99927cd47ea9423be88 (patch) | |
| tree | ec525a4eba3e6eb002cdfd9d6dee294a5533255d /packages/client/src/scripts/get-user-menu.ts | |
| parent | Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop (diff) | |
| download | sharkey-ea9aeef9d8790db51c59a99927cd47ea9423be88.tar.gz sharkey-ea9aeef9d8790db51c59a99927cd47ea9423be88.tar.bz2 sharkey-ea9aeef9d8790db51c59a99927cd47ea9423be88.zip | |
refactor(client): refactor dialog functions to improve type inference
Diffstat (limited to 'packages/client/src/scripts/get-user-menu.ts')
| -rw-r--r-- | packages/client/src/scripts/get-user-menu.ts | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/packages/client/src/scripts/get-user-menu.ts b/packages/client/src/scripts/get-user-menu.ts index 8d767afa25..0c04547101 100644 --- a/packages/client/src/scripts/get-user-menu.ts +++ b/packages/client/src/scripts/get-user-menu.ts @@ -14,21 +14,17 @@ export function getUserMenu(user) { const t = i18n.locale.selectList; // なぜか後で参照すると null になるので最初にメモリに確保しておく const lists = await os.api('users/lists/list'); if (lists.length === 0) { - os.dialog({ + os.alert({ type: 'error', text: i18n.locale.youHaveNoLists }); return; } - const { canceled, result: listId } = await os.dialog({ - type: null, + const { canceled, result: listId } = await os.select({ title: t, - select: { - items: lists.map(list => ({ - value: list.id, text: list.name - })) - }, - showCancelButton: true + items: lists.map(list => ({ + value: list.id, text: list.name + })) }); if (canceled) return; os.apiWithDialog('users/lists/push', { @@ -40,21 +36,17 @@ export function getUserMenu(user) { async function inviteGroup() { const groups = await os.api('users/groups/owned'); if (groups.length === 0) { - os.dialog({ + os.alert({ type: 'error', text: i18n.locale.youHaveNoGroups }); return; } - const { canceled, result: groupId } = await os.dialog({ - type: null, + const { canceled, result: groupId } = await os.select({ title: i18n.locale.group, - select: { - items: groups.map(group => ({ - value: group.id, text: group.name - })) - }, - showCancelButton: true + items: groups.map(group => ({ + value: group.id, text: group.name + })) }); if (canceled) return; os.apiWithDialog('users/groups/invite', { @@ -108,9 +100,8 @@ export function getUserMenu(user) { } async function getConfirmed(text: string): Promise<boolean> { - const confirm = await os.dialog({ + const confirm = await os.confirm({ type: 'warning', - showCancelButton: true, title: 'confirm', text, }); |