fix duplicate mandatory CWs in following feed

This commit is contained in:
Hazelnoot 2025-09-12 14:07:43 -04:00
parent f3d7229c55
commit 84ffc6361b
2 changed files with 14 additions and 11 deletions

View file

@ -20,7 +20,7 @@ Selectable entry on the "Following" feed, displaying a user with their most rece
</MkA>
</header>
<div>
<Mfm :class="$style.text" :text="getNoteSummary(note)" :isBlock="true" :plain="true" :nowrap="false" :isNote="true" nyaize="respect" :author="note.user"/>
<Mfm :class="$style.text" :text="getNoteSummary(note, false)" :isBlock="true" :plain="true" :nowrap="false" :isNote="true" nyaize="respect" :author="note.user"/>
</div>
</div>
</SkMutedNote>

View file

@ -9,9 +9,10 @@ import { i18n } from '@/i18n.js';
/**
* 稿
* @param {*} note (packされた)稿
* @param note (packされた)稿
* @param withMandatoryCw if true (default), include the note/user/instance mandatory CW
*/
export const getNoteSummary = (note?: Misskey.entities.Note | null): string => {
export const getNoteSummary = (note: Misskey.entities.Note | null | undefined, withMandatoryCw = true): string => {
if (note == null) {
return '';
}
@ -28,14 +29,16 @@ export const getNoteSummary = (note?: Misskey.entities.Note | null): string => {
// Append mandatory CW, if applicable
let cw = note.cw;
if (note.mandatoryCW) {
cw = appendContentWarning(cw, note.mandatoryCW);
}
if (note.user.mandatoryCW) {
cw = appendContentWarning(cw, note.user.mandatoryCW);
}
if (note.user.instance?.mandatoryCW) {
cw = appendContentWarning(cw, note.user.instance.mandatoryCW);
if (withMandatoryCw) {
if (note.mandatoryCW) {
cw = appendContentWarning(cw, note.mandatoryCW);
}
if (note.user.mandatoryCW) {
cw = appendContentWarning(cw, note.user.mandatoryCW);
}
if (note.user.instance?.mandatoryCW) {
cw = appendContentWarning(cw, note.user.instance.mandatoryCW);
}
}
// 本文