From ef5accd92cdf6b736704baf1bd2bb1b6ce47d031 Mon Sep 17 00:00:00 2001 From: ShittyKopper Date: Sat, 29 Jul 2023 15:24:20 +0300 Subject: [PATCH] feat: expand all CWs in thread https://iceshrimp.dev/iceshrimp/iceshrimp/issues/38 --- locales/en-US.yml | 2 ++ packages/client/src/components/MkNote.vue | 3 +++ packages/client/src/components/MkNoteDetailed.vue | 6 ++++++ packages/client/src/components/MkNoteSub.vue | 3 +++ .../client/src/components/MkSubNoteContent.vue | 10 +++++++++- packages/client/src/pages/note.vue | 14 +++++++++++++- 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/locales/en-US.yml b/locales/en-US.yml index 7d4003744..aebaa3112 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -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" diff --git a/packages/client/src/components/MkNote.vue b/packages/client/src/components/MkNote.vue index 25c0ee228..062e31ff5 100644 --- a/packages/client/src/components/MkNote.vue +++ b/packages/client/src/components/MkNote.vue @@ -14,6 +14,7 @@
(); const inChannel = inject("inChannel", null); diff --git a/packages/client/src/components/MkNoteDetailed.vue b/packages/client/src/components/MkNoteDetailed.vue index 27e2f78c8..988569d5e 100644 --- a/packages/client/src/components/MkNoteDetailed.vue +++ b/packages/client/src/components/MkNoteDetailed.vue @@ -16,6 +16,7 @@ class="reply-to" :note="note" :detailedView="true" + :forceExpandCw="props.expandAllCws" /> @@ -72,6 +75,7 @@ :conversation="replies" :detailedView="true" :parentId="note.id" + :forceExpandCw="props.expandAllCws" /> @@ -84,6 +88,7 @@ :conversation="replies" :detailedView="true" :parentId="note.id" + :forceExpandCw="props.expandAllCws" /> @@ -186,6 +191,7 @@ import appear from "@/directives/appear"; const props = defineProps<{ note: misskey.entities.Note; pinned?: boolean; + expandAllCws?: boolean; }>(); let tab = $ref("replies"); diff --git a/packages/client/src/components/MkNoteSub.vue b/packages/client/src/components/MkNoteSub.vue index ab6ce11a3..f3fbe5a0b 100644 --- a/packages/client/src/components/MkNoteSub.vue +++ b/packages/client/src/components/MkNoteSub.vue @@ -35,6 +35,7 @@ :parentId="parentId" :conversation="conversation" :detailedView="detailedView" + :forceExpandCw="props.forceExpandCw" @focusfooter="footerEl.focus()" />
@@ -148,6 +149,7 @@ :replyLevel="replyLevel + 1" :parentId="appearNote.id" :detailedView="detailedView" + :forceExpandCw="props.forceExpandCw" />
@@ -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; diff --git a/packages/client/src/components/MkSubNoteContent.vue b/packages/client/src/components/MkSubNoteContent.vue index b0fccc1f7..58ad5e5dc 100644 --- a/packages/client/src/components/MkSubNoteContent.vue +++ b/packages/client/src/components/MkSubNoteContent.vue @@ -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)) diff --git a/packages/client/src/pages/note.vue b/packages/client/src/pages/note.vue index 3e5059e5a..3079b3bfe 100644 --- a/packages/client/src/pages/note.vue +++ b/packages/client/src/pages/note.vue @@ -39,6 +39,7 @@
@@ -91,6 +92,7 @@ let showNext = $ref(false); let error = $ref(); let isRenote = $ref(false); let appearNote = $ref(); +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(() => []);