summaryrefslogtreecommitdiff
path: root/packages/client/src/scripts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-03-04 20:23:53 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-03-04 20:23:53 +0900
commite68278f93e82ba396ea2b1fbe0c7e0231c640421 (patch)
tree19fbe3831469e227b949e5f4030599f1aec9e5f5 /packages/client/src/scripts
parentfix query error (diff)
downloadsharkey-e68278f93e82ba396ea2b1fbe0c7e0231c640421.tar.gz
sharkey-e68278f93e82ba396ea2b1fbe0c7e0231c640421.tar.bz2
sharkey-e68278f93e82ba396ea2b1fbe0c7e0231c640421.zip
feat: 時限ミュート
#7677
Diffstat (limited to 'packages/client/src/scripts')
-rw-r--r--packages/client/src/scripts/get-user-menu.ts43
1 files changed, 38 insertions, 5 deletions
diff --git a/packages/client/src/scripts/get-user-menu.ts b/packages/client/src/scripts/get-user-menu.ts
index 6d1f25a942..192d14b83e 100644
--- a/packages/client/src/scripts/get-user-menu.ts
+++ b/packages/client/src/scripts/get-user-menu.ts
@@ -56,11 +56,44 @@ export function getUserMenu(user) {
}
async function toggleMute() {
- os.apiWithDialog(user.isMuted ? 'mute/delete' : 'mute/create', {
- userId: user.id
- }).then(() => {
- user.isMuted = !user.isMuted;
- });
+ 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() {