diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-05-10 20:01:26 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-05-12 21:46:03 -0400 |
| commit | 05e5be821885ea0a1d79f15b8aa7d26e542e9c2e (patch) | |
| tree | 28d05f45a6847938a09ab6481f9260bcbe7f4cf9 /packages/frontend/src/components/MkNoteSub.vue | |
| parent | return actual muted word from check-word-mute.ts (diff) | |
| download | sharkey-05e5be821885ea0a1d79f15b8aa7d26e542e9c2e.tar.gz sharkey-05e5be821885ea0a1d79f15b8aa7d26e542e9c2e.tar.bz2 sharkey-05e5be821885ea0a1d79f15b8aa7d26e542e9c2e.zip | |
show muted words in NoteDetailed / NoteSub components
Diffstat (limited to 'packages/frontend/src/components/MkNoteSub.vue')
| -rw-r--r-- | packages/frontend/src/components/MkNoteSub.vue | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/packages/frontend/src/components/MkNoteSub.vue b/packages/frontend/src/components/MkNoteSub.vue index 9751dbbc5c..c017efa3f3 100644 --- a/packages/frontend/src/components/MkNoteSub.vue +++ b/packages/frontend/src/components/MkNoteSub.vue @@ -73,19 +73,33 @@ SPDX-License-Identifier: AGPL-3.0-only </div> </div> <div v-else :class="$style.muted" @click="muted = false"> - <I18n :src="i18n.ts.userSaysSomething" tag="small"> + <I18n v-if="muted === 'sensitiveMute'" :src="i18n.ts.userSaysSomethingSensitive" tag="small"> <template #name> <MkUserName :user="appearNote.user"/> </template> </I18n> + <I18n v-else-if="showSoftWordMutedWord !== true" :src="i18n.ts.userSaysSomething" tag="small"> + <template #name> + <MkUserName :user="appearNote.user"/> + </template> + </I18n> + <I18n v-else :src="i18n.ts.userSaysSomethingAbout" tag="small"> + <template #name> + <MkUserName :user="appearNote.user"/> + </template> + <template #word> + {{ Array.isArray(muted) ? muted.map(words => Array.isArray(words) ? words.join() : words).slice(0, 3).join(' ') : muted }} + </template> + </I18n> </div> </template> <script lang="ts" setup> -import { computed, ref, shallowRef, watch } from 'vue'; +import { computed, inject, ref, shallowRef, watch } from 'vue'; import * as Misskey from 'misskey-js'; import { computeMergedCw } from '@@/js/compute-merged-cw.js'; import { host } from '@@/js/config.js'; +import type { Ref } from 'vue'; import type { Visibility } from '@/utility/boost-quote.js'; import type { OpenOnRemoteOptions } from '@/utility/please-login.js'; import MkNoteHeader from '@/components/MkNoteHeader.vue'; @@ -126,7 +140,6 @@ const props = withDefaults(defineProps<{ const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i?.id); const el = shallowRef<HTMLElement>(); -const muted = computed(() => $i ? checkWordMute(props.note, $i, $i.mutedWords) : false); const translation = ref<any>(null); const translating = ref(false); const isDeleted = ref(false); @@ -170,6 +183,36 @@ async function removeReply(id: Misskey.entities.Note['id']) { } } +const inTimeline = inject<boolean>('inTimeline', false); +const tl_withSensitive = inject<Ref<boolean>>('tl_withSensitive', ref(true)); +const muted = ref(checkMute(appearNote.value, $i?.mutedWords)); +const showSoftWordMutedWord = computed(() => prefer.s.showSoftWordMutedWord); + +/* Overload FunctionにLintが対応していないのでコメントアウト +function checkMute(noteToCheck: Misskey.entities.Note, mutedWords: Array<string | string[]> | undefined | null, checkOnly: true): boolean; +function checkMute(noteToCheck: Misskey.entities.Note, mutedWords: Array<string | string[]> | undefined | null, checkOnly: false): Array<string | string[]> | false | 'sensitiveMute'; +*/ +function checkMute(noteToCheck: Misskey.entities.Note, mutedWords: Array<string | string[]> | undefined | null, checkOnly = false): Array<string | string[]> | false | 'sensitiveMute' { + if (mutedWords != null) { + const result = checkWordMute(noteToCheck, $i, mutedWords); + if (Array.isArray(result)) return result; + + const replyResult = noteToCheck.reply && checkWordMute(noteToCheck.reply, $i, mutedWords); + if (Array.isArray(replyResult)) return replyResult; + + const renoteResult = noteToCheck.renote && checkWordMute(noteToCheck.renote, $i, mutedWords); + if (Array.isArray(renoteResult)) return renoteResult; + } + + if (checkOnly) return false; + + if (inTimeline && tl_withSensitive.value === false && noteToCheck.files?.some((v) => v.isSensitive)) { + return 'sensitiveMute'; + } + + return false; +} + useNoteCapture({ rootEl: el, note: appearNote, |