Skip to content

Commit

Permalink
fix: メニューから凍結できるように変更
Browse files Browse the repository at this point in the history
  • Loading branch information
nacika-ins committed Jun 13, 2024
1 parent 9d26987 commit e90e8bd
Showing 1 changed file with 68 additions and 36 deletions.
104 changes: 68 additions & 36 deletions packages/frontend/src/scripts/get-user-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
}
}

async function toggleRenoteMute() {
os.apiWithDialog(user.isRenoteMuted ? 'renote-mute/delete' : 'renote-mute/create', {
userId: user.id,
}).then(() => {
user.isRenoteMuted = !user.isRenoteMuted;
});
}
async function toggleRenoteMute() {
os.apiWithDialog(user.isRenoteMuted ? 'renote-mute/delete' : 'renote-mute/create', {
userId: user.id,
}).then(() => {
user.isRenoteMuted = !user.isRenoteMuted;
});
}

async function toggleBlock() {
if (!(await getConfirmed(user.isBlocking ? i18n.ts.unblockConfirm : i18n.ts.blockConfirm))) return;
Expand Down Expand Up @@ -192,7 +192,7 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
icon: 'ti ti-mail',
text: i18n.ts.sendMessage,
action: () => {
os.post({ specified: user, initialText: `@${user.username} ` });
os.post({ specified: user, initialText: `@${user.username} ` });
},
},
meId !== user.id
Expand Down Expand Up @@ -251,32 +251,49 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
.filter((r) => r.target === 'manual')
.map((r) => ({
text: r.name,
action: async () => {
const { canceled, result: period } = await os.select({
title: i18n.ts.period,
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;
action: async () => {
const { canceled, result: period } = await os.select({
title: i18n.ts.period,
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;

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;
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 });
os.apiWithDialog('admin/roles/assign', { roleId: r.id, userId: user.id, expiresAt });
},
}));
},
Expand All @@ -292,10 +309,11 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
action: toggleMute,
},
{
icon: user.isRenoteMuted ? 'ti ti-repeat' : 'ti ti-repeat-off',
text: user.isRenoteMuted ? i18n.ts.renoteUnmute : i18n.ts.renoteMute,
action: toggleRenoteMute,
}, {
icon: user.isRenoteMuted ? 'ti ti-repeat' : 'ti ti-repeat-off',
text: user.isRenoteMuted ? i18n.ts.renoteUnmute : i18n.ts.renoteMute,
action: toggleRenoteMute,
},
{
icon: 'ti ti-ban',
text: user.isBlocking ? i18n.ts.unblock : i18n.ts.block,
action: toggleBlock,
Expand Down Expand Up @@ -324,6 +342,20 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
if (iAmModerator) {
menu = menu.concat([
null,
{
icon: 'ti ti-ban',
text: user.isSuspended ? i18n.ts.unsuspend : i18n.ts.suspend,
action: async () => {
const { canceled } = await os.confirm({
type: 'warning',
text: user.isSuspended ? i18n.ts.unsuspendConfirm : i18n.ts.suspendConfirm,
});

if (canceled) return;

os.apiWithDialog(user.isSuspended ? 'admin/unsuspend-user' : 'admin/suspend-user', { userId: user.id });
},
},
{
icon: 'ti ti-user-exclamation',
text: i18n.ts.moderation,
Expand Down

0 comments on commit e90e8bd

Please sign in to comment.