feat: expand all CWs in thread

https://iceshrimp.dev/iceshrimp/iceshrimp/issues/38
This commit is contained in:
ShittyKopper 2023-07-29 15:24:20 +03:00
parent 8737e2fa71
commit ef5accd92c
6 changed files with 36 additions and 2 deletions

View file

@ -64,6 +64,8 @@ showMore: "Show more"
newer: "newer"
older: "older"
showLess: "Close"
expandAllCws: "Show content for all replies"
collapseAllCws: "Hide content for all replies"
youGotNewFollower: "followed you"
receiveFollowRequest: "Follow request received"
followRequestAccepted: "Follow request accepted"

View file

@ -14,6 +14,7 @@
<MkNoteSub
v-if="appearNote.reply && !detailedView && !collapsedReply"
:note="appearNote.reply"
:forceExpandCw="props.forceExpandCw"
class="reply-to"
/>
<div
@ -105,6 +106,7 @@
:detailed="true"
:detailedView="detailedView"
:parentId="appearNote.parentId"
:forceExpandCw="props.forceExpandCw"
@push="(e) => router.push(notePage(e))"
@focusfooter="footerEl.focus()"
@expanded="(e) => setPostExpanded(e)"
@ -298,6 +300,7 @@ const props = defineProps<{
pinned?: boolean;
detailedView?: boolean;
collapsedReply?: boolean;
forceExpandCw?: boolean;
}>();
const inChannel = inject("inChannel", null);

View file

@ -16,6 +16,7 @@
class="reply-to"
:note="note"
:detailedView="true"
:forceExpandCw="props.expandAllCws"
/>
<MkLoading v-else-if="note.reply" mini />
<MkNoteSub
@ -23,6 +24,7 @@
:note="note.reply"
class="reply-to"
:detailedView="true"
:forceExpandCw="props.expandAllCws"
/>
<MkNote
@ -31,6 +33,7 @@
tabindex="-1"
:note="note"
detailedView
:forceExpandCw="props.expandAllCws"
></MkNote>
<MkTab v-model="tab" :style="'underline'" @update:modelValue="loadTab">
@ -72,6 +75,7 @@
:conversation="replies"
:detailedView="true"
:parentId="note.id"
:forceExpandCw="props.expandAllCws"
/>
<MkLoading v-else-if="tab === 'replies' && note.repliesCount > 0" />
@ -84,6 +88,7 @@
:conversation="replies"
:detailedView="true"
:parentId="note.id"
:forceExpandCw="props.expandAllCws"
/>
<MkLoading v-else-if="tab === 'quotes' && directQuotes.length > 0" />
@ -186,6 +191,7 @@ import appear from "@/directives/appear";
const props = defineProps<{
note: misskey.entities.Note;
pinned?: boolean;
expandAllCws?: boolean;
}>();
let tab = $ref("replies");

View file

@ -35,6 +35,7 @@
:parentId="parentId"
:conversation="conversation"
:detailedView="detailedView"
:forceExpandCw="props.forceExpandCw"
@focusfooter="footerEl.focus()"
/>
<div v-if="translating || translation" class="translation">
@ -148,6 +149,7 @@
:replyLevel="replyLevel + 1"
:parentId="appearNote.id"
:detailedView="detailedView"
:forceExpandCw="props.forceExpandCw"
/>
<div v-else-if="replies.length > 0" class="more">
<div class="line"></div>
@ -211,6 +213,7 @@ const props = withDefaults(
conversation?: misskey.entities.Note[];
parentId?;
detailedView?;
forceExpandCw?: boolean;
// how many notes are in between this one and the note being viewed in detail
depth?: number;

View file

@ -215,6 +215,7 @@ const props = defineProps<{
conversation?;
detailed?: boolean;
detailedView?: boolean;
forceExpandCw?: boolean;
}>();
const emit = defineEmits<{
@ -238,7 +239,14 @@ const urls = props.note.text
? extractUrlFromMfm(mfm.parse(props.note.text)).slice(0, 5)
: null;
let showContent = $ref(false);
let _showContent = $ref(null);
let showContent = $computed({
set(val) { _showContent = val },
get() {
if (_showContent != null) return _showContent;
return props.forceExpandCw || false;
},
})
const mfms = props.note.text
? extractMfmWithAnimation(mfm.parse(props.note.text))

View file

@ -39,6 +39,7 @@
<XNoteDetailed
:key="appearNote.id"
v-model:note="appearNote"
:expandAllCws="expandAllCws"
class="note"
/>
</div>
@ -91,6 +92,7 @@ let showNext = $ref(false);
let error = $ref();
let isRenote = $ref(false);
let appearNote = $ref<null | misskey.entities.Note>();
let expandAllCws = $ref(false);
const prevPagination = {
endpoint: "users/notes" as const,
@ -160,11 +162,21 @@ function fetchNote() {
});
}
function toggleAllCws() {
expandAllCws = !expandAllCws;
}
watch(() => props.noteId, fetchNote, {
immediate: true,
});
const headerActions = $computed(() => []);
const headerActions = $computed(() => appearNote ? [
{
icon: `${expandAllCws ? "ph-eye" : "ph-eye-slash"} ph-bold ph-lg`,
text: expandAllCws ? i18n.ts.collapseAllCws : i18n.ts.expandAllCws,
handler: toggleAllCws,
},
]:[]);
const headerTabs = $computed(() => []);