chore: collapse renotes of sensitive channel on basic timelines

This commit is contained in:
anatawa12 2025-12-17 01:19:51 +09:00
parent 99a4553923
commit 0a3cee85b4
No known key found for this signature in database
GPG Key ID: 9CA909848B8E4EA6
8 changed files with 30 additions and 10 deletions

View File

@ -270,7 +270,7 @@ const emit = defineEmits<{
// for some timelines, like home timeline which only shows the following channels,
// we never collapse sensitive channel notes so we allow inject to override the preference
const collapseSensitiveChannel: boolean = inject<boolean | undefined>('collapseSensitiveChannel', undefined) ?? prefer.s.collapseSensitiveChannel;
const collapseSensitiveChannelContext = inject(DI.collapseSensitiveChannel, true);
const inTimeline = inject<boolean>('inTimeline', false);
const tl_withSensitive = inject<Ref<boolean>>('tl_withSensitive', ref(true));
const inChannel = inject('inChannel', null);
@ -362,7 +362,20 @@ function checkMute(noteToCheck: Misskey.entities.Note, mutedWords: Array<string
if (checkOnly) return false;
if (collapseSensitiveChannel && noteToCheck.channel?.isSensitive) return 'sensitiveChannel';
if (noteToCheck.channel?.isSensitive) {
if (prefer.s.collapseSensitiveChannel) {
switch (collapseSensitiveChannelContext) {
case true: return 'sensitiveChannel';
case 'renote-only':
if (note.channel?.id !== appearNote.channel?.id) {
return 'sensitiveChannel';
}
break;
case false:
break;
}
}
}
if (inTimeline && tl_withSensitive.value === false && noteToCheck.files?.some((v) => v.isSensitive)) {
return 'sensitiveMute';
}

View File

@ -18,4 +18,5 @@ export const DI = {
mfmEmojiReactCallback: Symbol() as InjectionKey<(emoji: string) => void>,
inModal: Symbol() as InjectionKey<boolean>,
inAppSearchMarkerId: Symbol() as InjectionKey<Ref<string | null>>,
collapseSensitiveChannel: Symbol() as InjectionKey<boolean | 'renote-only'>,
};

View File

@ -99,6 +99,7 @@ import { notesSearchAvailable } from '@/utility/check-permissions.js';
import { miLocalStorage } from '@/local-storage.js';
import { useRouter } from '@/router.js';
import { Paginator } from '@/utility/paginator.js';
import { DI } from '@/di';
const router = useRouter();
@ -107,7 +108,7 @@ const props = defineProps<{
}>();
//
provide('collapseSensitiveChannel', false);
provide(DI.collapseSensitiveChannel, false);
const tab = ref('overview');

View File

@ -28,13 +28,14 @@ import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { definePage } from '@/page.js';
import { Paginator } from '@/utility/paginator.js';
import { DI } from '@/di';
const tab = ref('all');
const includeTypes = ref<string[] | null>(null);
const excludeTypes = computed(() => includeTypes.value ? notificationTypes.filter(t => !includeTypes.value!.includes(t)) : null);
// 稿
provide('collapseSensitiveChannel', false);
provide(DI.collapseSensitiveChannel, false);
const mentionsPaginator = markRaw(new Paginator('notes/mentions', {
limit: 10,

View File

@ -44,11 +44,12 @@ import { deepMerge } from '@/utility/merge.js';
import { miLocalStorage } from '@/local-storage.js';
import { availableBasicTimelines, hasWithReplies, isAvailableBasicTimeline, isBasicTimeline, basicTimelineIconClass } from '@/timelines.js';
import { prefer } from '@/preferences.js';
import { DI } from '@/di';
const tlComponent = useTemplateRef('tlComponent');
//
provide('collapseSensitiveChannel', false);
//
provide(DI.collapseSensitiveChannel, 'renote-only');
type TimelinePageSrc = BasicTimelineType | `list:${string}`;

View File

@ -33,6 +33,7 @@ import { favoritedChannelsCache } from '@/cache.js';
import { misskeyApi } from '@/utility/misskey-api.js';
import { i18n } from '@/i18n.js';
import { soundSettingsButton } from '@/ui/deck/tl-note-notification.js';
import { DI } from '@/di';
const props = defineProps<{
column: Column;
@ -40,7 +41,7 @@ const props = defineProps<{
}>();
//
provide('collapseSensitiveChannel', false);
provide(DI.collapseSensitiveChannel, false);
const timeline = useTemplateRef('timeline');
const channel = shallowRef<Misskey.entities.Channel>();

View File

@ -19,6 +19,7 @@ import { updateColumn } from '@/deck.js';
import MkStreamingNotificationsTimeline from '@/components/MkStreamingNotificationsTimeline.vue';
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { DI } from '@/di';
const props = defineProps<{
column: Column;
@ -26,7 +27,7 @@ const props = defineProps<{
}>();
// 稿
provide('collapseSensitiveChannel', false);
provide(DI.collapseSensitiveChannel, false);
const notificationsComponent = useTemplateRef('notificationsComponent');

View File

@ -44,14 +44,15 @@ import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { hasWithReplies, isAvailableBasicTimeline, basicTimelineIconClass } from '@/timelines.js';
import { soundSettingsButton } from '@/ui/deck/tl-note-notification.js';
import { DI } from '@/di';
const props = defineProps<{
column: Column;
isStacked: boolean;
}>();
//
provide('collapseSensitiveChannel', false);
//
provide(DI.collapseSensitiveChannel, 'renote-only');
const timeline = useTemplateRef('timeline');