feat(frontend): hide or collapse note of sensitive channel

This commit is contained in:
anatawa12 2023-08-06 19:52:15 +09:00
parent 03f01b6ffc
commit 62b75bb61b
No known key found for this signature in database
GPG Key ID: 9CA909848B8E4EA6
5 changed files with 12 additions and 6 deletions

View File

@ -175,6 +175,7 @@ import { notePage } from '@/filters/note';
const props = defineProps<{
note: misskey.entities.Note;
pinned?: boolean;
collapseSensitiveChannel?: boolean;
}>();
const inChannel = inject('inChannel', null);
@ -210,7 +211,7 @@ let appearNote = $computed(() => isRenote ? note.renote as misskey.entities.Note
const isMyRenote = $i && ($i.id === note.userId);
const showContent = ref(false);
const urls = appearNote.text ? extractUrlFromMfm(mfm.parse(appearNote.text)) : null;
const isLong = shouldCollapsed(appearNote);
const isLong = shouldCollapsed(appearNote, props.collapseSensitiveChannel ?? false);
const collapsed = ref(appearNote.cw == null && isLong);
const isDeleted = ref(false);
const muted = ref(checkWordMute(appearNote, $i, defaultStore.state.mutedWords));

View File

@ -19,7 +19,7 @@
:ad="true"
:class="$style.notes"
>
<MkNote :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note"/>
<MkNote :key="note._featuredId_ || note._prId_ || note.id" :class="$style.note" :note="note" :collapseSensitiveChannel="props.collapseSensitiveChannel"/>
</MkDateSeparatedList>
</div>
</template>
@ -37,6 +37,7 @@ import { infoImageUrl } from '@/instance';
const props = defineProps<{
pagination: Paging;
noGap?: boolean;
collapseSensitiveChannel?: boolean;
}>();
const pagingComponent = shallowRef<InstanceType<typeof MkPagination>>();

View File

@ -125,7 +125,7 @@
<XPhotos :key="user.id" :user="user"/>
<XActivity :key="user.id" :user="user"/>
</template>
<MkNotes v-if="!disableNotes" :class="$style.tl" :noGap="true" :pagination="pagination"/>
<MkNotes v-if="!disableNotes" :class="$style.tl" :noGap="true" :pagination="pagination" :collapseSensitiveChannel="true"/>
</div>
</div>
<div v-if="!narrow" class="sub _gaps" style="container-type: inline-size;">
@ -194,6 +194,7 @@ const pagination = {
limit: 10,
params: computed(() => ({
userId: props.user.id,
includeSensitiveChannel: $i != null,
})),
};

View File

@ -8,7 +8,7 @@
<option value="files">{{ i18n.ts.withFiles }}</option>
</MkTab>
</template>
<MkNotes :noGap="true" :pagination="pagination" :class="$style.tl"/>
<MkNotes :noGap="true" :pagination="pagination" :class="$style.tl" :collapseSensitiveChannel="true"/>
</MkStickyContainer>
</MkSpacer>
</template>
@ -19,6 +19,7 @@ import * as misskey from 'misskey-js';
import MkNotes from '@/components/MkNotes.vue';
import MkTab from '@/components/MkTab.vue';
import { i18n } from '@/i18n';
import { $i } from '@/account';
const props = defineProps<{
user: misskey.entities.UserDetailed;
@ -33,6 +34,7 @@ const pagination = {
userId: props.user.id,
includeReplies: include.value === 'replies' || include.value === 'files',
withFiles: include.value === 'files',
includeSensitiveChannel: $i != null,
})),
};
</script>

View File

@ -2,7 +2,7 @@ import * as mfm from 'mfm-js';
import * as misskey from 'misskey-js';
import { extractUrlFromMfm } from './extract-url-from-mfm';
export function shouldCollapsed(note: misskey.entities.Note): boolean {
export function shouldCollapsed(note: misskey.entities.Note, collapseSensitiveChannel = false): boolean {
const urls = note.text ? extractUrlFromMfm(mfm.parse(note.text)) : null;
const collapsed = note.cw == null && note.text != null && (
(note.text.includes('$[x2')) ||
@ -12,7 +12,8 @@ export function shouldCollapsed(note: misskey.entities.Note): boolean {
(note.text.split('\n').length > 9) ||
(note.text.length > 500) ||
(note.files.length >= 5) ||
(!!urls && urls.length >= 4)
(!!urls && urls.length >= 4) ||
collapseSensitiveChannel ? note.channel?.isSensitive : false
);
return collapsed;