mirror of
https://github.com/MisskeyIO/misskey
synced 2024-12-26 12:38:16 +09:00
a89003b57a
* update stream.ts * https://github.com/misskey-dev/misskey/pull/7769#issuecomment-917542339 * fix lint * clean up? * add app * fix * nanka iroiro * wip * wip * fix lint * fix loginId * fix * refactor * refactor * remove follow action * clean up * Revert "remove follow action" This reverts commit defbb416480905af2150d1c92f10d8e1d1288c0a. * Revert "clean up" This reverts commit f94919cb9cff41e274044fc69c56ad36a33974f2. * remove fetch specification * renoteの条件追加 * apiFetch => cli * bypass fetch? * fix * refactor: use path alias * temp: add submodule * remove submodule * enhane: unison-reloadに指定したパスに移動できるように * null * null * feat: ログインするアカウントのIDをクエリ文字列で指定する機能 * null * await? * rename * rename * Update read.ts * merge * get-note-summary * fix * swパッケージに * add missing packages * fix getNoteSummary * add webpack-cli * ✌️ * remove plugins * sw-inject分離したがテストしてない * fix notification.vue * remove a blank line * disconnect intersection observer * disconnect2 * fix notification.vue * remove a blank line * disconnect intersection observer * disconnect2 * fix * ✌️ * clean up config * typesを戻した * Update packages/client/src/components/notification.vue Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> * disconnect * oops * Failed to load the script unexpectedly回避 sw.jsとlib.tsを分離してみた * truncate notification * Update packages/client/src/ui/_common_/common.vue Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * clean up * clean up * キャッシュ対策 * Truncate push notification message * クライアントがあったらストリームに接続しているということなので通知しない判定の位置を修正 * components/drive-file-thumbnail.vue * components/drive-select-dialog.vue * components/drive-window.vue * merge * fix * Service Workerのビルドにesbuildを使うようにする * return createEmptyNotification() * fix * i18n.ts * update * ✌️ * remove ts-loader * fix * fix * enhance: Service Workerを常に登録するように * pollEnded * URLをsw.jsに戻す * clean up * wip * wip * wip * wip * wip * wip * ✌️ * use import * fix * install rollup * use defineAsyncComponent. * fix emojilist * wip use defineAsyncComponent * popup(import -> popup(defineAsyncComponent(() => import * draggable? * fix init import * clean up * fix router * add comment * ✌️ * ✌️ * ✌️ * remove webpack * update vite * fix boot sequence * Revert "fix boot sequence" This reverts commit e893dbf37aed83bf9f12e427d98c78a7065b4a39. * revert boot import * never make two app div * ; * remove console.log * change clientEntry sequence * fix * Revert "fix" This reverts commit 12741b3d89950a31dbb1bb81477ddb27b0e9951a. * fix * add comment https://github.com/misskey-dev/misskey/pull/8575#issuecomment-1114239210 * add log * add comment Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
247 lines
6.0 KiB
TypeScript
247 lines
6.0 KiB
TypeScript
import { i18n } from '@/i18n';
|
|
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
|
import { host } from '@/config';
|
|
import * as Acct from 'misskey-js/built/acct';
|
|
import * as os from '@/os';
|
|
import { userActions } from '@/store';
|
|
import { router } from '@/router';
|
|
import { $i, iAmModerator } from '@/account';
|
|
import { defineAsyncComponent } from 'vue';
|
|
|
|
export function getUserMenu(user) {
|
|
const meId = $i ? $i.id : null;
|
|
|
|
async function pushList() {
|
|
const t = i18n.ts.selectList; // なぜか後で参照すると null になるので最初にメモリに確保しておく
|
|
const lists = await os.api('users/lists/list');
|
|
if (lists.length === 0) {
|
|
os.alert({
|
|
type: 'error',
|
|
text: i18n.ts.youHaveNoLists
|
|
});
|
|
return;
|
|
}
|
|
const { canceled, result: listId } = await os.select({
|
|
title: t,
|
|
items: lists.map(list => ({
|
|
value: list.id, text: list.name
|
|
}))
|
|
});
|
|
if (canceled) return;
|
|
os.apiWithDialog('users/lists/push', {
|
|
listId: listId,
|
|
userId: user.id
|
|
});
|
|
}
|
|
|
|
async function inviteGroup() {
|
|
const groups = await os.api('users/groups/owned');
|
|
if (groups.length === 0) {
|
|
os.alert({
|
|
type: 'error',
|
|
text: i18n.ts.youHaveNoGroups
|
|
});
|
|
return;
|
|
}
|
|
const { canceled, result: groupId } = await os.select({
|
|
title: i18n.ts.group,
|
|
items: groups.map(group => ({
|
|
value: group.id, text: group.name
|
|
}))
|
|
});
|
|
if (canceled) return;
|
|
os.apiWithDialog('users/groups/invite', {
|
|
groupId: groupId,
|
|
userId: user.id
|
|
});
|
|
}
|
|
|
|
async function toggleMute() {
|
|
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;
|
|
});
|
|
}
|
|
}
|
|
|
|
async function toggleBlock() {
|
|
if (!await getConfirmed(user.isBlocking ? i18n.ts.unblockConfirm : i18n.ts.blockConfirm)) return;
|
|
|
|
os.apiWithDialog(user.isBlocking ? 'blocking/delete' : 'blocking/create', {
|
|
userId: user.id
|
|
}).then(() => {
|
|
user.isBlocking = !user.isBlocking;
|
|
});
|
|
}
|
|
|
|
async function toggleSilence() {
|
|
if (!await getConfirmed(i18n.t(user.isSilenced ? 'unsilenceConfirm' : 'silenceConfirm'))) return;
|
|
|
|
os.apiWithDialog(user.isSilenced ? 'admin/unsilence-user' : 'admin/silence-user', {
|
|
userId: user.id
|
|
}).then(() => {
|
|
user.isSilenced = !user.isSilenced;
|
|
});
|
|
}
|
|
|
|
async function toggleSuspend() {
|
|
if (!await getConfirmed(i18n.t(user.isSuspended ? 'unsuspendConfirm' : 'suspendConfirm'))) return;
|
|
|
|
os.apiWithDialog(user.isSuspended ? 'admin/unsuspend-user' : 'admin/suspend-user', {
|
|
userId: user.id
|
|
}).then(() => {
|
|
user.isSuspended = !user.isSuspended;
|
|
});
|
|
}
|
|
|
|
function reportAbuse() {
|
|
os.popup(defineAsyncComponent(() => import('@/components/abuse-report-window.vue')), {
|
|
user: user,
|
|
}, {}, 'closed');
|
|
}
|
|
|
|
async function getConfirmed(text: string): Promise<boolean> {
|
|
const confirm = await os.confirm({
|
|
type: 'warning',
|
|
title: 'confirm',
|
|
text,
|
|
});
|
|
|
|
return !confirm.canceled;
|
|
}
|
|
|
|
async function invalidateFollow() {
|
|
os.apiWithDialog('following/invalidate', {
|
|
userId: user.id
|
|
}).then(() => {
|
|
user.isFollowed = !user.isFollowed;
|
|
})
|
|
}
|
|
|
|
let menu = [{
|
|
icon: 'fas fa-at',
|
|
text: i18n.ts.copyUsername,
|
|
action: () => {
|
|
copyToClipboard(`@${user.username}@${user.host || host}`);
|
|
}
|
|
}, {
|
|
icon: 'fas fa-info-circle',
|
|
text: i18n.ts.info,
|
|
action: () => {
|
|
os.pageWindow(`/user-info/${user.id}`);
|
|
}
|
|
}, {
|
|
icon: 'fas fa-envelope',
|
|
text: i18n.ts.sendMessage,
|
|
action: () => {
|
|
os.post({ specified: user });
|
|
}
|
|
}, meId != user.id ? {
|
|
type: 'link',
|
|
icon: 'fas fa-comments',
|
|
text: i18n.ts.startMessaging,
|
|
to: '/my/messaging/' + Acct.toString(user),
|
|
} : undefined, null, {
|
|
icon: 'fas fa-list-ul',
|
|
text: i18n.ts.addToList,
|
|
action: pushList
|
|
}, meId != user.id ? {
|
|
icon: 'fas fa-users',
|
|
text: i18n.ts.inviteToGroup,
|
|
action: inviteGroup
|
|
} : undefined] as any;
|
|
|
|
if ($i && meId != user.id) {
|
|
menu = menu.concat([null, {
|
|
icon: user.isMuted ? 'fas fa-eye' : 'fas fa-eye-slash',
|
|
text: user.isMuted ? i18n.ts.unmute : i18n.ts.mute,
|
|
action: toggleMute
|
|
}, {
|
|
icon: 'fas fa-ban',
|
|
text: user.isBlocking ? i18n.ts.unblock : i18n.ts.block,
|
|
action: toggleBlock
|
|
}]);
|
|
|
|
if (user.isFollowed) {
|
|
menu = menu.concat([{
|
|
icon: 'fas fa-unlink',
|
|
text: i18n.ts.breakFollow,
|
|
action: invalidateFollow
|
|
}]);
|
|
}
|
|
|
|
menu = menu.concat([null, {
|
|
icon: 'fas fa-exclamation-circle',
|
|
text: i18n.ts.reportAbuse,
|
|
action: reportAbuse
|
|
}]);
|
|
|
|
if (iAmModerator) {
|
|
menu = menu.concat([null, {
|
|
icon: 'fas fa-microphone-slash',
|
|
text: user.isSilenced ? i18n.ts.unsilence : i18n.ts.silence,
|
|
action: toggleSilence
|
|
}, {
|
|
icon: 'fas fa-snowflake',
|
|
text: user.isSuspended ? i18n.ts.unsuspend : i18n.ts.suspend,
|
|
action: toggleSuspend
|
|
}]);
|
|
}
|
|
}
|
|
|
|
if ($i && meId === user.id) {
|
|
menu = menu.concat([null, {
|
|
icon: 'fas fa-pencil-alt',
|
|
text: i18n.ts.editProfile,
|
|
action: () => {
|
|
router.push('/settings/profile');
|
|
}
|
|
}]);
|
|
}
|
|
|
|
if (userActions.length > 0) {
|
|
menu = menu.concat([null, ...userActions.map(action => ({
|
|
icon: 'fas fa-plug',
|
|
text: action.title,
|
|
action: () => {
|
|
action.handler(user);
|
|
}
|
|
}))]);
|
|
}
|
|
|
|
return menu;
|
|
}
|