From 620be4a9e122a13d856ed96e7491c88377db546f Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Sun, 3 Dec 2023 19:35:39 +0100 Subject: [PATCH] add: auto uncollapse CW on all notes option Closes transfem-org/Sharkey#191 --- packages/frontend/src/components/MkNote.vue | 2 +- packages/frontend/src/components/MkNoteDetailed.vue | 2 +- packages/frontend/src/components/MkNoteSimple.vue | 3 ++- packages/frontend/src/components/MkNoteSub.vue | 2 +- packages/frontend/src/components/SkNote.vue | 2 +- packages/frontend/src/components/SkNoteDetailed.vue | 2 +- packages/frontend/src/components/SkNoteSimple.vue | 3 ++- packages/frontend/src/components/SkNoteSub.vue | 2 +- packages/frontend/src/pages/settings/general.vue | 4 +++- packages/frontend/src/store.ts | 4 ++++ 10 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 4da8f16df1..bfc03cff7b 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -271,7 +271,7 @@ const renoteUrl = appearNote.renote ? appearNote.renote.url : null; const renoteUri = appearNote.renote ? appearNote.renote.uri : null; const isMyRenote = $i && ($i.id === note.userId); -const showContent = ref(false); +const showContent = ref(defaultStore.state.uncollapseCW); const parsed = $computed(() => appearNote.text ? mfm.parse(appearNote.text) : null); const urls = $computed(() => parsed ? extractUrlFromMfm(parsed).filter(u => u !== renoteUrl && u !== renoteUri) : null); const animated = $computed(() => parsed ? checkAnimationFromMfm(parsed) : null); diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index 30198d2a6a..a6baeb6e1f 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -306,7 +306,7 @@ const renoteUrl = appearNote.renote ? appearNote.renote.url : null; const renoteUri = appearNote.renote ? appearNote.renote.uri : null; const isMyRenote = $i && ($i.id === note.userId); -const showContent = ref(false); +const showContent = ref(defaultStore.state.uncollapseCW); const isDeleted = ref(false); const renoted = ref(false); const muted = ref($i ? checkWordMute(appearNote, $i, $i.mutedWords) : false); diff --git a/packages/frontend/src/components/MkNoteSimple.vue b/packages/frontend/src/components/MkNoteSimple.vue index b1d4ed3f7e..bc0f82d44d 100644 --- a/packages/frontend/src/components/MkNoteSimple.vue +++ b/packages/frontend/src/components/MkNoteSimple.vue @@ -28,6 +28,7 @@ import MkNoteHeader from '@/components/MkNoteHeader.vue'; import MkSubNoteContent from '@/components/MkSubNoteContent.vue'; import MkCwButton from '@/components/MkCwButton.vue'; import { $i } from '@/account.js'; +import { defaultStore } from '@/store.js'; const props = defineProps<{ note: Misskey.entities.Note; @@ -35,7 +36,7 @@ const props = defineProps<{ hideFiles?: boolean; }>(); -let showContent = $ref(false); +let showContent = $ref(defaultStore.state.uncollapseCW); watch(() => props.expandAllCws, (expandAllCws) => { if (expandAllCws !== showContent) showContent = expandAllCws; diff --git a/packages/frontend/src/components/MkNoteSub.vue b/packages/frontend/src/components/MkNoteSub.vue index 3e33c7aa69..1e057abacf 100644 --- a/packages/frontend/src/components/MkNoteSub.vue +++ b/packages/frontend/src/components/MkNoteSub.vue @@ -244,7 +244,7 @@ function undoRenote() : void { } } -let showContent = $ref(false); +let showContent = $ref(defaultStore.state.uncollapseCW); watch(() => props.expandAllCws, (expandAllCws) => { if (expandAllCws !== showContent) showContent = expandAllCws; diff --git a/packages/frontend/src/components/SkNote.vue b/packages/frontend/src/components/SkNote.vue index 924437def5..0a48173ac6 100644 --- a/packages/frontend/src/components/SkNote.vue +++ b/packages/frontend/src/components/SkNote.vue @@ -272,7 +272,7 @@ const renoteUrl = appearNote.renote ? appearNote.renote.url : null; const renoteUri = appearNote.renote ? appearNote.renote.uri : null; const isMyRenote = $i && ($i.id === note.userId); -const showContent = ref(false); +const showContent = ref(defaultStore.state.uncollapseCW); const parsed = $computed(() => appearNote.text ? mfm.parse(appearNote.text) : null); const urls = $computed(() => parsed ? extractUrlFromMfm(parsed).filter(u => u !== renoteUrl && u !== renoteUri) : null); const animated = $computed(() => parsed ? checkAnimationFromMfm(parsed) : null); diff --git a/packages/frontend/src/components/SkNoteDetailed.vue b/packages/frontend/src/components/SkNoteDetailed.vue index 91db2047e0..79d279aaed 100644 --- a/packages/frontend/src/components/SkNoteDetailed.vue +++ b/packages/frontend/src/components/SkNoteDetailed.vue @@ -314,7 +314,7 @@ const renoteUrl = appearNote.renote ? appearNote.renote.url : null; const renoteUri = appearNote.renote ? appearNote.renote.uri : null; const isMyRenote = $i && ($i.id === note.userId); -const showContent = ref(false); +const showContent = ref(defaultStore.state.uncollapseCW); const isDeleted = ref(false); const renoted = ref(false); const muted = ref($i ? checkWordMute(appearNote, $i, $i.mutedWords) : false); diff --git a/packages/frontend/src/components/SkNoteSimple.vue b/packages/frontend/src/components/SkNoteSimple.vue index 8ebd24b322..05a19e291d 100644 --- a/packages/frontend/src/components/SkNoteSimple.vue +++ b/packages/frontend/src/components/SkNoteSimple.vue @@ -28,6 +28,7 @@ import MkNoteHeader from '@/components/MkNoteHeader.vue'; import MkSubNoteContent from '@/components/MkSubNoteContent.vue'; import MkCwButton from '@/components/MkCwButton.vue'; import { $i } from '@/account.js'; +import { defaultStore } from '@/store.js'; const props = defineProps<{ note: Misskey.entities.Note; @@ -35,7 +36,7 @@ const props = defineProps<{ hideFiles?: boolean; }>(); -let showContent = $ref(false); +let showContent = $ref(defaultStore.state.uncollapseCW); watch(() => props.expandAllCws, (expandAllCws) => { if (expandAllCws !== showContent) showContent = expandAllCws; diff --git a/packages/frontend/src/components/SkNoteSub.vue b/packages/frontend/src/components/SkNoteSub.vue index bbad1680ac..90c550f6b1 100644 --- a/packages/frontend/src/components/SkNoteSub.vue +++ b/packages/frontend/src/components/SkNoteSub.vue @@ -253,7 +253,7 @@ function undoRenote() : void { } } -let showContent = $ref(false); +let showContent = $ref(defaultStore.state.uncollapseCW); watch(() => props.expandAllCws, (expandAllCws) => { if (expandAllCws !== showContent) showContent = expandAllCws; diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 51be3b21b5..5e9be51fa6 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -47,6 +47,7 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.showClipButtonInNoteFooter }} {{ i18n.ts.collapseRenotes }} {{ i18n.ts.collapseFiles }} + Uncollapse CWs on notes {{ i18n.ts.autoloadConversation }} {{ i18n.ts.enableAdvancedMfm }} {{ i18n.ts.enableAnimatedMfm }} @@ -63,7 +64,7 @@ SPDX-License-Identifier: AGPL-3.0-only - + @@ -279,6 +280,7 @@ const disableStreamingTimeline = computed(defaultStore.makeGetterSetter('disable const useGroupedNotifications = computed(defaultStore.makeGetterSetter('useGroupedNotifications')); const showTickerOnReplies = computed(defaultStore.makeGetterSetter('showTickerOnReplies')); const noteDesign = computed(defaultStore.makeGetterSetter('noteDesign')); +const uncollapseCW = computed(defaultStore.makeGetterSetter('uncollapseCW')); watch(lang, () => { miLocalStorage.setItem('lang', lang.value as string); diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index e823e84eb6..1863995bc1 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -74,6 +74,10 @@ export const defaultStore = markRaw(new Storage('base', { where: 'account', default: false, }, + uncollapseCW: { + where: 'account', + default: false, + }, rememberNoteVisibility: { where: 'account', default: false,