2023-07-27 00:31:52 -05:00
|
|
|
/*
|
2024-02-13 09:59:27 -06:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 00:31:52 -05:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-07-10 01:55:10 -05:00
|
|
|
import { toUnicode } from 'punycode';
|
2023-08-01 01:32:03 -05:00
|
|
|
import { defineAsyncComponent, ref, watch } from 'vue';
|
2023-09-03 23:33:38 -05:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { i18n } from '@/i18n.js';
|
2024-07-17 07:52:05 -05:00
|
|
|
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { host, url } from '@/config.js';
|
|
|
|
import * as os from '@/os.js';
|
2024-01-04 03:32:46 -06:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { defaultStore, userActions } from '@/store.js';
|
|
|
|
import { $i, iAmModerator } from '@/account.js';
|
2024-07-30 01:51:08 -05:00
|
|
|
import { notesSearchAvailable, canSearchNonLocalNotes } from '@/scripts/check-permissions.js';
|
2024-01-07 23:44:43 -06:00
|
|
|
import { IRouter } from '@/nirax.js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { antennasCache, rolesCache, userListsCache } from '@/cache.js';
|
2024-01-30 06:07:34 -06:00
|
|
|
import { mainRouter } from '@/router/main.js';
|
2024-07-30 05:55:18 -05:00
|
|
|
import { MenuItem } from '@/types/menu.js';
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2024-01-07 23:44:43 -06:00
|
|
|
export function getUserMenu(user: Misskey.entities.UserDetailed, router: IRouter = mainRouter) {
|
2020-12-18 19:55:52 -06:00
|
|
|
const meId = $i ? $i.id : null;
|
2020-11-28 20:25:43 -06:00
|
|
|
|
2023-08-01 01:32:03 -05:00
|
|
|
const cleanups = [] as (() => void)[];
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
async function toggleMute() {
|
2022-03-04 05:23:53 -06:00
|
|
|
if (user.isMuted) {
|
|
|
|
os.apiWithDialog('mute/delete', {
|
|
|
|
userId: user.id,
|
|
|
|
}).then(() => {
|
|
|
|
user.isMuted = false;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
const { canceled, result: period } = await os.select({
|
|
|
|
title: i18n.ts.mutePeriod,
|
|
|
|
items: [{
|
|
|
|
value: 'indefinitely', text: i18n.ts.indefinitely,
|
|
|
|
}, {
|
|
|
|
value: 'tenMinutes', text: i18n.ts.tenMinutes,
|
|
|
|
}, {
|
|
|
|
value: 'oneHour', text: i18n.ts.oneHour,
|
|
|
|
}, {
|
|
|
|
value: 'oneDay', text: i18n.ts.oneDay,
|
|
|
|
}, {
|
|
|
|
value: 'oneWeek', text: i18n.ts.oneWeek,
|
|
|
|
}],
|
|
|
|
default: 'indefinitely',
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
const expiresAt = period === 'indefinitely' ? null
|
|
|
|
: period === 'tenMinutes' ? Date.now() + (1000 * 60 * 10)
|
|
|
|
: period === 'oneHour' ? Date.now() + (1000 * 60 * 60)
|
|
|
|
: period === 'oneDay' ? Date.now() + (1000 * 60 * 60 * 24)
|
|
|
|
: period === 'oneWeek' ? Date.now() + (1000 * 60 * 60 * 24 * 7)
|
|
|
|
: null;
|
|
|
|
|
|
|
|
os.apiWithDialog('mute/create', {
|
|
|
|
userId: user.id,
|
|
|
|
expiresAt,
|
|
|
|
}).then(() => {
|
|
|
|
user.isMuted = true;
|
|
|
|
});
|
|
|
|
}
|
2020-10-17 06:12:00 -05:00
|
|
|
}
|
|
|
|
|
2023-03-07 17:56:09 -06:00
|
|
|
async function toggleRenoteMute() {
|
|
|
|
os.apiWithDialog(user.isRenoteMuted ? 'renote-mute/delete' : 'renote-mute/create', {
|
|
|
|
userId: user.id,
|
|
|
|
}).then(() => {
|
|
|
|
user.isRenoteMuted = !user.isRenoteMuted;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
async function toggleBlock() {
|
2022-01-27 20:39:49 -06:00
|
|
|
if (!await getConfirmed(user.isBlocking ? i18n.ts.unblockConfirm : i18n.ts.blockConfirm)) return;
|
2020-10-17 06:12:00 -05:00
|
|
|
|
|
|
|
os.apiWithDialog(user.isBlocking ? 'blocking/delete' : 'blocking/create', {
|
2022-06-20 03:38:49 -05:00
|
|
|
userId: user.id,
|
2020-10-17 06:12:00 -05:00
|
|
|
}).then(() => {
|
|
|
|
user.isBlocking = !user.isBlocking;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-09-21 04:48:15 -05:00
|
|
|
async function toggleNotify() {
|
|
|
|
os.apiWithDialog('following/update', {
|
|
|
|
userId: user.id,
|
|
|
|
notify: user.notify === 'normal' ? 'none' : 'normal',
|
|
|
|
}).then(() => {
|
|
|
|
user.notify = user.notify === 'normal' ? 'none' : 'normal';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:22:55 -06:00
|
|
|
function reportAbuse() {
|
2024-07-03 23:14:49 -05:00
|
|
|
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), {
|
2020-10-19 05:29:04 -05:00
|
|
|
user: user,
|
2024-07-03 23:14:49 -05:00
|
|
|
}, {
|
|
|
|
closed: () => dispose(),
|
|
|
|
});
|
2020-10-19 05:29:04 -05:00
|
|
|
}
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
async function getConfirmed(text: string): Promise<boolean> {
|
2021-11-18 03:45:58 -06:00
|
|
|
const confirm = await os.confirm({
|
2020-10-17 06:12:00 -05:00
|
|
|
type: 'warning',
|
|
|
|
title: 'confirm',
|
|
|
|
text,
|
|
|
|
});
|
|
|
|
|
|
|
|
return !confirm.canceled;
|
|
|
|
}
|
|
|
|
|
2023-10-29 02:14:48 -05:00
|
|
|
async function userInfoUpdate() {
|
|
|
|
os.apiWithDialog('federation/update-remote-user', {
|
|
|
|
userId: user.id,
|
|
|
|
});
|
|
|
|
}
|
2023-12-11 19:26:37 -06:00
|
|
|
|
2021-12-02 20:14:44 -06:00
|
|
|
async function invalidateFollow() {
|
2023-02-23 22:08:06 -06:00
|
|
|
if (!await getConfirmed(i18n.ts.breakFollowConfirm)) return;
|
|
|
|
|
2021-12-02 20:14:44 -06:00
|
|
|
os.apiWithDialog('following/invalidate', {
|
2022-06-20 03:38:49 -05:00
|
|
|
userId: user.id,
|
2021-12-02 20:14:44 -06:00
|
|
|
}).then(() => {
|
|
|
|
user.isFollowed = !user.isFollowed;
|
2022-06-10 00:36:55 -05:00
|
|
|
});
|
2021-12-02 20:14:44 -06:00
|
|
|
}
|
|
|
|
|
2023-04-12 23:50:17 -05:00
|
|
|
async function editMemo(): Promise<void> {
|
2024-01-04 03:32:46 -06:00
|
|
|
const userDetailed = await misskeyApi('users/show', {
|
2023-04-12 23:50:17 -05:00
|
|
|
userId: user.id,
|
|
|
|
});
|
|
|
|
const { canceled, result } = await os.form(i18n.ts.editMemo, {
|
|
|
|
memo: {
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
multiline: true,
|
|
|
|
label: i18n.ts.memo,
|
|
|
|
default: userDetailed.memo,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
os.apiWithDialog('users/update-memo', {
|
|
|
|
memo: result.memo,
|
|
|
|
userId: user.id,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-07-30 05:55:18 -05:00
|
|
|
let menu: MenuItem[] = [{
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-at',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: i18n.ts.copyUsername,
|
2020-10-17 06:12:00 -05:00
|
|
|
action: () => {
|
2023-02-25 03:27:15 -06:00
|
|
|
copyToClipboard(`@${user.username}@${user.host ?? host}`);
|
2022-06-20 03:38:49 -05:00
|
|
|
},
|
2024-07-30 01:51:08 -05:00
|
|
|
}, ...( notesSearchAvailable && (user.host == null || canSearchNonLocalNotes) ? [{
|
|
|
|
icon: 'ti ti-search',
|
|
|
|
text: i18n.ts.searchThisUsersNotes,
|
|
|
|
action: () => {
|
|
|
|
router.push(`/search?username=${encodeURIComponent(user.username)}${user.host != null ? '&host=' + encodeURIComponent(user.host) : ''}`);
|
|
|
|
},
|
|
|
|
}] : [])
|
|
|
|
, ...(iAmModerator ? [{
|
2023-08-13 07:02:25 -05:00
|
|
|
icon: 'ti ti-user-exclamation',
|
|
|
|
text: i18n.ts.moderation,
|
2021-04-16 03:34:06 -05:00
|
|
|
action: () => {
|
2023-08-13 07:02:25 -05:00
|
|
|
router.push(`/admin/user/${user.id}`);
|
2022-06-20 03:38:49 -05:00
|
|
|
},
|
2023-08-13 07:02:25 -05:00
|
|
|
}] : []), {
|
2022-12-27 18:10:33 -06:00
|
|
|
icon: 'ti ti-rss',
|
|
|
|
text: i18n.ts.copyRSS,
|
|
|
|
action: () => {
|
|
|
|
copyToClipboard(`${user.host ?? host}/@${user.username}.atom`);
|
|
|
|
},
|
2024-01-27 03:25:15 -06:00
|
|
|
}, ...(user.host != null && user.url != null ? [{
|
|
|
|
icon: 'ti ti-external-link',
|
|
|
|
text: i18n.ts.showOnRemote,
|
|
|
|
action: () => {
|
|
|
|
if (user.url == null) return;
|
|
|
|
window.open(user.url, '_blank', 'noopener');
|
|
|
|
},
|
|
|
|
}] : []), {
|
2023-07-09 03:20:50 -05:00
|
|
|
icon: 'ti ti-share',
|
|
|
|
text: i18n.ts.copyProfileUrl,
|
|
|
|
action: () => {
|
2023-07-09 08:46:17 -05:00
|
|
|
const canonical = user.host === null ? `@${user.username}` : `@${user.username}@${toUnicode(user.host)}`;
|
2023-07-09 03:20:50 -05:00
|
|
|
copyToClipboard(`${url}/${canonical}`);
|
|
|
|
},
|
2024-07-14 01:27:52 -05:00
|
|
|
}, ...($i ? [{
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-mail',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: i18n.ts.sendMessage,
|
2020-10-17 06:12:00 -05:00
|
|
|
action: () => {
|
2023-08-20 03:54:11 -05:00
|
|
|
const canonical = user.host === null ? `@${user.username}` : `@${user.username}@${user.host}`;
|
|
|
|
os.post({ specified: user, initialText: `${canonical} ` });
|
2022-06-20 03:38:49 -05:00
|
|
|
},
|
2023-12-11 19:26:37 -06:00
|
|
|
}, { type: 'divider' }, {
|
2023-04-12 23:50:17 -05:00
|
|
|
icon: 'ti ti-pencil',
|
|
|
|
text: i18n.ts.editMemo,
|
|
|
|
action: () => {
|
|
|
|
editMemo();
|
|
|
|
},
|
|
|
|
}, {
|
2023-02-25 20:57:37 -06:00
|
|
|
type: 'parent',
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-list',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: i18n.ts.addToList,
|
2023-02-25 20:57:37 -06:00
|
|
|
children: async () => {
|
2023-09-11 00:55:18 -05:00
|
|
|
const lists = await userListsCache.fetch();
|
2023-08-01 01:32:03 -05:00
|
|
|
return lists.map(list => {
|
|
|
|
const isListed = ref(list.userIds.includes(user.id));
|
|
|
|
cleanups.push(watch(isListed, () => {
|
|
|
|
if (isListed.value) {
|
|
|
|
os.apiWithDialog('users/lists/push', {
|
|
|
|
listId: list.id,
|
|
|
|
userId: user.id,
|
|
|
|
}).then(() => {
|
|
|
|
list.userIds.push(user.id);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
os.apiWithDialog('users/lists/pull', {
|
|
|
|
listId: list.id,
|
|
|
|
userId: user.id,
|
|
|
|
}).then(() => {
|
|
|
|
list.userIds.splice(list.userIds.indexOf(user.id), 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}));
|
2023-02-25 20:57:37 -06:00
|
|
|
|
2023-08-01 01:32:03 -05:00
|
|
|
return {
|
|
|
|
type: 'switch',
|
|
|
|
text: list.name,
|
|
|
|
ref: isListed,
|
|
|
|
};
|
|
|
|
});
|
2023-07-10 01:55:10 -05:00
|
|
|
},
|
|
|
|
}, {
|
|
|
|
type: 'parent',
|
|
|
|
icon: 'ti ti-antenna',
|
|
|
|
text: i18n.ts.addToAntenna,
|
|
|
|
children: async () => {
|
2023-09-11 00:55:18 -05:00
|
|
|
const antennas = await antennasCache.fetch();
|
2023-07-10 01:55:10 -05:00
|
|
|
const canonical = user.host === null ? `@${user.username}` : `@${user.username}@${toUnicode(user.host)}`;
|
|
|
|
return antennas.filter((a) => a.src === 'users').map(antenna => ({
|
|
|
|
text: antenna.name,
|
|
|
|
action: async () => {
|
|
|
|
await os.apiWithDialog('antennas/update', {
|
|
|
|
antennaId: antenna.id,
|
|
|
|
name: antenna.name,
|
|
|
|
keywords: antenna.keywords,
|
|
|
|
excludeKeywords: antenna.excludeKeywords,
|
|
|
|
src: antenna.src,
|
|
|
|
userListId: antenna.userListId,
|
|
|
|
users: [...antenna.users, canonical],
|
|
|
|
caseSensitive: antenna.caseSensitive,
|
|
|
|
withReplies: antenna.withReplies,
|
|
|
|
withFile: antenna.withFile,
|
|
|
|
notify: antenna.notify,
|
|
|
|
});
|
|
|
|
antennasCache.delete();
|
2023-02-25 20:57:37 -06:00
|
|
|
},
|
|
|
|
}));
|
|
|
|
},
|
2024-07-14 01:27:52 -05:00
|
|
|
}] : [])] as any;
|
2020-10-17 06:12:00 -05:00
|
|
|
|
2022-05-07 00:19:15 -05:00
|
|
|
if ($i && meId !== user.id) {
|
2023-02-25 20:57:37 -06:00
|
|
|
if (iAmModerator) {
|
|
|
|
menu = menu.concat([{
|
|
|
|
type: 'parent',
|
|
|
|
icon: 'ti ti-badges',
|
|
|
|
text: i18n.ts.roles,
|
|
|
|
children: async () => {
|
2023-09-11 00:55:18 -05:00
|
|
|
const roles = await rolesCache.fetch();
|
2023-02-25 20:57:37 -06:00
|
|
|
|
|
|
|
return roles.filter(r => r.target === 'manual').map(r => ({
|
|
|
|
text: r.name,
|
2023-02-28 19:20:03 -06:00
|
|
|
action: async () => {
|
|
|
|
const { canceled, result: period } = await os.select({
|
2024-05-04 05:40:17 -05:00
|
|
|
title: i18n.ts.period + ': ' + r.name,
|
2023-02-28 19:20:03 -06:00
|
|
|
items: [{
|
|
|
|
value: 'indefinitely', text: i18n.ts.indefinitely,
|
|
|
|
}, {
|
|
|
|
value: 'oneHour', text: i18n.ts.oneHour,
|
|
|
|
}, {
|
|
|
|
value: 'oneDay', text: i18n.ts.oneDay,
|
|
|
|
}, {
|
|
|
|
value: 'oneWeek', text: i18n.ts.oneWeek,
|
|
|
|
}, {
|
|
|
|
value: 'oneMonth', text: i18n.ts.oneMonth,
|
|
|
|
}],
|
|
|
|
default: 'indefinitely',
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2023-07-07 17:08:16 -05:00
|
|
|
|
2023-02-28 19:20:03 -06:00
|
|
|
const expiresAt = period === 'indefinitely' ? null
|
|
|
|
: period === 'oneHour' ? Date.now() + (1000 * 60 * 60)
|
|
|
|
: period === 'oneDay' ? Date.now() + (1000 * 60 * 60 * 24)
|
|
|
|
: period === 'oneWeek' ? Date.now() + (1000 * 60 * 60 * 24 * 7)
|
|
|
|
: period === 'oneMonth' ? Date.now() + (1000 * 60 * 60 * 24 * 30)
|
|
|
|
: null;
|
|
|
|
|
|
|
|
os.apiWithDialog('admin/roles/assign', { roleId: r.id, userId: user.id, expiresAt });
|
2023-02-25 20:57:37 -06:00
|
|
|
},
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
}]);
|
|
|
|
}
|
|
|
|
|
2023-09-21 04:48:15 -05:00
|
|
|
// フォローしたとしても user.isFollowing はリアルタイム更新されないので不便なため
|
|
|
|
//if (user.isFollowing) {
|
2024-07-30 05:55:18 -05:00
|
|
|
const withRepliesRef = ref(user.withReplies);
|
2023-09-21 04:48:15 -05:00
|
|
|
menu = menu.concat([{
|
2024-07-30 05:55:18 -05:00
|
|
|
type: 'switch',
|
|
|
|
icon: 'ti ti-messages',
|
|
|
|
text: i18n.ts.showRepliesToOthersInTimeline,
|
|
|
|
ref: withRepliesRef,
|
2023-10-03 06:26:11 -05:00
|
|
|
}, {
|
2023-09-21 04:48:15 -05:00
|
|
|
icon: user.notify === 'none' ? 'ti ti-bell' : 'ti ti-bell-off',
|
|
|
|
text: user.notify === 'none' ? i18n.ts.notifyNotes : i18n.ts.unnotifyNotes,
|
|
|
|
action: toggleNotify,
|
|
|
|
}]);
|
2024-07-30 05:55:18 -05:00
|
|
|
watch(withRepliesRef, (withReplies) => {
|
|
|
|
misskeyApi('following/update', {
|
|
|
|
userId: user.id,
|
|
|
|
withReplies,
|
|
|
|
}).then(() => {
|
|
|
|
user.withReplies = withReplies;
|
|
|
|
});
|
|
|
|
});
|
2023-09-21 04:48:15 -05:00
|
|
|
//}
|
|
|
|
|
2023-12-11 19:26:37 -06:00
|
|
|
menu = menu.concat([{ type: 'divider' }, {
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: user.isMuted ? 'ti ti-eye' : 'ti ti-eye-off',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: user.isMuted ? i18n.ts.unmute : i18n.ts.mute,
|
2022-06-20 03:38:49 -05:00
|
|
|
action: toggleMute,
|
2023-03-07 17:56:09 -06:00
|
|
|
}, {
|
|
|
|
icon: user.isRenoteMuted ? 'ti ti-repeat' : 'ti ti-repeat-off',
|
|
|
|
text: user.isRenoteMuted ? i18n.ts.renoteUnmute : i18n.ts.renoteMute,
|
|
|
|
action: toggleRenoteMute,
|
2020-10-17 06:12:00 -05:00
|
|
|
}, {
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-ban',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: user.isBlocking ? i18n.ts.unblock : i18n.ts.block,
|
2022-06-20 03:38:49 -05:00
|
|
|
action: toggleBlock,
|
2020-10-17 06:12:00 -05:00
|
|
|
}]);
|
|
|
|
|
2021-12-02 20:14:44 -06:00
|
|
|
if (user.isFollowed) {
|
|
|
|
menu = menu.concat([{
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-link-off',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: i18n.ts.breakFollow,
|
2022-06-20 03:38:49 -05:00
|
|
|
action: invalidateFollow,
|
2021-12-02 20:14:44 -06:00
|
|
|
}]);
|
|
|
|
}
|
|
|
|
|
2023-12-11 19:26:37 -06:00
|
|
|
menu = menu.concat([{ type: 'divider' }, {
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-exclamation-circle',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: i18n.ts.reportAbuse,
|
2022-06-20 03:38:49 -05:00
|
|
|
action: reportAbuse,
|
2020-10-19 05:29:04 -05:00
|
|
|
}]);
|
2020-10-17 06:12:00 -05:00
|
|
|
}
|
|
|
|
|
2023-10-29 02:14:48 -05:00
|
|
|
if (user.host !== null) {
|
2023-12-11 19:26:37 -06:00
|
|
|
menu = menu.concat([{ type: 'divider' }, {
|
2023-10-29 02:14:48 -05:00
|
|
|
icon: 'ti ti-refresh',
|
|
|
|
text: i18n.ts.updateRemoteUser,
|
|
|
|
action: userInfoUpdate,
|
|
|
|
}]);
|
|
|
|
}
|
2023-12-11 19:26:37 -06:00
|
|
|
|
2023-05-13 20:30:46 -05:00
|
|
|
if (defaultStore.state.devMode) {
|
2023-12-11 19:26:37 -06:00
|
|
|
menu = menu.concat([{ type: 'divider' }, {
|
2023-05-13 20:30:46 -05:00
|
|
|
icon: 'ti ti-id',
|
|
|
|
text: i18n.ts.copyUserId,
|
|
|
|
action: () => {
|
|
|
|
copyToClipboard(user.id);
|
|
|
|
},
|
|
|
|
}]);
|
|
|
|
}
|
|
|
|
|
2020-12-18 19:55:52 -06:00
|
|
|
if ($i && meId === user.id) {
|
2023-12-11 19:26:37 -06:00
|
|
|
menu = menu.concat([{ type: 'divider' }, {
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-pencil',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: i18n.ts.editProfile,
|
2020-10-17 06:12:00 -05:00
|
|
|
action: () => {
|
2022-07-16 02:52:12 -05:00
|
|
|
router.push('/settings/profile');
|
2022-06-20 03:38:49 -05:00
|
|
|
},
|
2020-10-17 06:12:00 -05:00
|
|
|
}]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (userActions.length > 0) {
|
2023-12-11 19:26:37 -06:00
|
|
|
menu = menu.concat([{ type: 'divider' }, ...userActions.map(action => ({
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-plug',
|
2020-10-17 06:12:00 -05:00
|
|
|
text: action.title,
|
|
|
|
action: () => {
|
|
|
|
action.handler(user);
|
2022-06-20 03:38:49 -05:00
|
|
|
},
|
2020-10-17 06:12:00 -05:00
|
|
|
}))]);
|
|
|
|
}
|
|
|
|
|
2023-08-01 01:32:03 -05:00
|
|
|
const cleanup = () => {
|
|
|
|
if (_DEV_) console.log('user menu cleanup', cleanups);
|
2023-08-08 19:08:47 -05:00
|
|
|
for (const cl of cleanups) {
|
|
|
|
cl();
|
|
|
|
}
|
2023-08-01 01:32:03 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
menu,
|
|
|
|
cleanup,
|
|
|
|
};
|
2020-10-17 06:12:00 -05:00
|
|
|
}
|