prompt to confirm before revoking token

This commit is contained in:
Hazelnoot 2025-06-21 21:56:31 -04:00
parent 5742aade4c
commit ac576ca7fc

View file

@ -67,6 +67,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import { ref, computed } from 'vue';
import * as Misskey from 'misskey-js';
import * as os from '@/os.js';
import FormPagination from '@/components/MkPagination.vue';
import { misskeyApi } from '@/utility/misskey-api.js';
import { i18n } from '@/i18n.js';
@ -87,9 +89,21 @@ const pagination = {
},
};
function revoke(token) {
misskeyApi('i/revoke-token', { tokenId: token.id }).then(() => {
list.value?.reload();
async function revoke(token: Misskey.entities.IAppsResponse[number]) {
const { canceled } = await os.confirm({
type: 'question',
text: token.grantees.length > 0
? i18n.tsx.confirmRevokeSharedToken({ num: token.grantees.length })
: i18n.ts.confirmRevokeToken,
okText: i18n.ts.yes,
cancelText: i18n.ts.no,
});
if (canceled) return;
await os.promiseDialog(async () => {
await misskeyApi('i/revoke-token', { tokenId: token.id });
await list.value?.reload();
});
}