mute notifications in muted threads #119

Merged
norm merged 7 commits from mute-notifications into main 2022-09-22 19:52:33 +00:00
3 changed files with 18 additions and 2 deletions
Showing only changes of commit 87411a6ed8 - Show all commits

View file

@ -805,6 +805,7 @@ makeReactionsPublicDescription: "あなたがしたリアクション一覧を
classic: "クラシック" classic: "クラシック"
muteThread: "スレッドをミュート" muteThread: "スレッドをミュート"
unmuteThread: "スレッドのミュートを解除" unmuteThread: "スレッドのミュートを解除"
threadMuteNotificationsDesc: "このスレッドから表示する通知を選択します。グローバル通知設定も適用され、禁止が優先されます。"
ffVisibility: "つながりの公開範囲" ffVisibility: "つながりの公開範囲"
ffVisibilityDescription: "自分のフォロー/フォロワー情報の公開範囲を設定できます。" ffVisibilityDescription: "自分のフォロー/フォロワー情報の公開範囲を設定できます。"
continueThread: "さらにスレッドを見る" continueThread: "さらにスレッドを見る"

View file

@ -1,5 +1,5 @@
import { noteNotificationTypes } from 'foundkey-js'; import { noteNotificationTypes } from 'foundkey-js';
import { Notes, NoteThreadMutings } from '@/models/index.js'; import { Notes, NoteThreadMutings, NoteWatchings } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import readNote from '@/services/note/read.js'; import readNote from '@/services/note/read.js';
import define from '../../../define.js'; import define from '../../../define.js';
@ -62,4 +62,17 @@ export default define(meta, paramDef, async (ps, user) => {
userId: user.id, userId: user.id,
mutingNotificationTypes: ps.mutingNotificationTypes, mutingNotificationTypes: ps.mutingNotificationTypes,
}); });
// remove all note watchings in the muted thread
const notesThread = Notes.createQueryBuilder("notes")
.select("note.id")
.where({
threadId: note.threadId ?? note.id,
});
await NoteWatchings.createQueryBuilder()
.delete()
.where(`"note_watching"."noteId" IN (${ notesThread.getQuery() })`)
.setParameters(notesThread.getParameters())
.execute();
}); });

View file

@ -18,7 +18,7 @@
</MkSwitch> </MkSwitch>
</div> </div>
<div v-if="!useGlobalSetting" class="_section"> <div v-if="!useGlobalSetting" class="_section">
<MkInfo>{{ i18n.ts.notificationSettingDesc }}</MkInfo> <MkInfo>{{ message }}</MkInfo>
<MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton> <MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton>
<MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton> <MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton>
<MkSwitch v-for="ntype in notificationTypes" :key="ntype" v-model="typesMap[ntype]">{{ i18n.t(`_notification._types.${ntype}`) }}</MkSwitch> <MkSwitch v-for="ntype in notificationTypes" :key="ntype" v-model="typesMap[ntype]">{{ i18n.t(`_notification._types.${ntype}`) }}</MkSwitch>
@ -44,10 +44,12 @@ const props = withDefaults(defineProps<{
includingTypes?: typeof foundkey.notificationTypes[number][] | null; includingTypes?: typeof foundkey.notificationTypes[number][] | null;
notificationTypes?: typeof foundkey.notificationTypes[number][] | null; notificationTypes?: typeof foundkey.notificationTypes[number][] | null;
showGlobalToggle?: boolean; showGlobalToggle?: boolean;
message?: string,
}>(), { }>(), {
includingTypes: () => [], includingTypes: () => [],
notificationTypes: () => [], notificationTypes: () => [],
showGlobalToggle: true, showGlobalToggle: true,
message: i18n.ts.notificationSettingDesc,
}); });
let includingTypes = $computed(() => props.includingTypes || []); let includingTypes = $computed(() => props.includingTypes || []);