summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkNote.vue
diff options
context:
space:
mode:
authorHazelnoot <acomputerdog@gmail.com>2025-05-12 23:28:55 -0400
committerHazelnoot <acomputerdog@gmail.com>2025-05-12 23:28:55 -0400
commitb52db71e1894e25cebfafc782d2cec86705e2cbb (patch)
treec3444a49a9507403a5e6cbd0a7f1a8fd4a0e10d9 /packages/frontend/src/components/MkNote.vue
parentsimplify access to showSoftWordMutedWord (diff)
downloadsharkey-b52db71e1894e25cebfafc782d2cec86705e2cbb.tar.gz
sharkey-b52db71e1894e25cebfafc782d2cec86705e2cbb.tar.bz2
sharkey-b52db71e1894e25cebfafc782d2cec86705e2cbb.zip
factor out shared word mute logic
Diffstat (limited to 'packages/frontend/src/components/MkNote.vue')
-rw-r--r--packages/frontend/src/components/MkNote.vue52
1 files changed, 4 insertions, 48 deletions
diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue
index 4ceefe300b..b4977b73bc 100644
--- a/packages/frontend/src/components/MkNote.vue
+++ b/packages/frontend/src/components/MkNote.vue
@@ -171,24 +171,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</article>
</div>
<div v-else-if="!hardMuted" :class="$style.muted" @click="muted = false">
- <I18n v-if="muted === 'sensitiveMute'" :src="i18n.ts.userSaysSomethingSensitive" tag="small">
- <template #name>
- <MkUserName :user="appearNote.user"/>
- </template>
- </I18n>
- <I18n v-else-if="prefer.s.showSoftWordMutedWord" :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>
+ <SkMutedNote :muted="muted" :note="appearNote"></SkMutedNote>
</div>
<div v-else>
<!--
@@ -224,7 +207,7 @@ import MkUrlPreview from '@/components/MkUrlPreview.vue';
import MkInstanceTicker from '@/components/MkInstanceTicker.vue';
import MkButton from '@/components/MkButton.vue';
import { pleaseLogin } from '@/utility/please-login.js';
-import { checkWordMute } from '@/utility/check-word-mute.js';
+import { checkMutes } from '@/utility/check-word-mute.js';
import { notePage } from '@/filters/note.js';
import { userPage } from '@/filters/user.js';
import number from '@/filters/number.js';
@@ -253,6 +236,7 @@ import { prefer } from '@/preferences.js';
import { getPluginHandlers } from '@/plugin.js';
import { DI } from '@/di.js';
import { useRouter } from '@/router.js';
+import SkMutedNote from '@/components/SkMutedNote.vue';
const props = withDefaults(defineProps<{
note: Misskey.entities.Note;
@@ -272,8 +256,6 @@ const emit = defineEmits<{
const router = useRouter();
-const inTimeline = inject<boolean>('inTimeline', false);
-const tl_withSensitive = inject<Ref<boolean>>('tl_withSensitive', ref(true));
const inChannel = inject('inChannel', null);
const currentClip = inject<Ref<Misskey.entities.Clip> | null>('currentClip', null);
@@ -327,8 +309,7 @@ const isLong = shouldCollapsed(appearNote.value, urls.value ?? []);
const collapsed = ref(prefer.s.expandLongNote && appearNote.value.cw == null && isLong ? false : appearNote.value.cw == null && isLong);
const isDeleted = ref(false);
const renoted = ref(false);
-const muted = ref(checkMute(appearNote.value, $i?.mutedWords));
-const hardMuted = ref(props.withHardMute && checkMute(appearNote.value, $i?.hardMutedWords, true));
+const { muted, hardMuted } = checkMutes(appearNote.value, props.withHardMute);
const translation = ref<Misskey.entities.NotesTranslateResponse | null>(null);
const translating = ref(false);
const showTicker = (prefer.s.instanceTicker === 'always') || (prefer.s.instanceTicker === 'remote' && appearNote.value.user.instance);
@@ -353,31 +334,6 @@ const mergedCW = computed(() => computeMergedCw(appearNote.value));
const renoteTooltip = computeRenoteTooltip(renoted);
-/* 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;
-}
-
let renoting = false;
const keymap = {