From fd4bb4d8647612ce8a100a2bdeb086fc67aaf0da Mon Sep 17 00:00:00 2001 From: Thomas Preece Date: Mon, 9 Jan 2023 06:54:39 +0000 Subject: [PATCH] feat: add option to always expand posts marked with content warnings (#2342) Co-authored-by: Nolan Lawson --- src/intl/en-US.js | 1 + src/routes/_components/status/Status.html | 2 +- .../_components/status/StatusSpoiler.html | 5 ++- src/routes/_pages/settings/general.html | 5 +++ src/routes/_store/store.js | 1 + tests/spec/043-content-warnings.js | 37 +++++++++++++++++++ 6 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 tests/spec/043-content-warnings.js diff --git a/src/intl/en-US.js b/src/intl/en-US.js index 88de2b78..046a1c57 100644 --- a/src/intl/en-US.js +++ b/src/intl/en-US.js @@ -368,6 +368,7 @@ export default { general: 'General', generalSettings: 'General settings', showSensitive: 'Show sensitive media by default', + showAllSpoilers: 'Expand content warnings by default', showPlain: 'Show a plain gray color for sensitive media', allSensitive: 'Treat all media as sensitive', largeMedia: 'Show large inline images and videos', diff --git a/src/routes/_components/status/Status.html b/src/routes/_components/status/Status.html index 3d9e28d7..2370276b 100644 --- a/src/routes/_components/status/Status.html +++ b/src/routes/_components/status/Status.html @@ -260,7 +260,7 @@ notification && notification.status && notification.type !== 'mention' && notification.status.id === originalStatusId ), - spoilerShown: ({ $spoilersShown, uuid }) => !!$spoilersShown[uuid], + spoilerShown: ({ $spoilersShown, uuid, $showAllSpoilers }) => (typeof $spoilersShown[uuid] === 'undefined' ? !!$showAllSpoilers : !!$spoilersShown[uuid]), replyShown: ({ $repliesShown, uuid }) => !!$repliesShown[uuid], showCard: ({ originalStatus, isStatusInNotification, showMedia, $hideCards }) => ( !$hideCards && diff --git a/src/routes/_components/status/StatusSpoiler.html b/src/routes/_components/status/StatusSpoiler.html index 06af8af0..d89054df 100644 --- a/src/routes/_components/status/StatusSpoiler.html +++ b/src/routes/_components/status/StatusSpoiler.html @@ -76,8 +76,9 @@ methods: { toggleSpoilers (shown) { const { uuid } = this.get() - const { spoilersShown } = this.store.get() - spoilersShown[uuid] = typeof shown === 'undefined' ? !spoilersShown[uuid] : !!shown + const { spoilersShown, showAllSpoilers } = this.store.get() + const currentValue = typeof spoilersShown[uuid] === 'undefined' ? !!showAllSpoilers : spoilersShown[uuid] + spoilersShown[uuid] = typeof shown === 'undefined' ? !currentValue : !!shown this.store.set({ spoilersShown }) requestAnimationFrame(() => { mark('clickSpoilerButton') diff --git a/src/routes/_pages/settings/general.html b/src/routes/_pages/settings/general.html index dd95e882..11981a82 100644 --- a/src/routes/_pages/settings/general.html +++ b/src/routes/_pages/settings/general.html @@ -8,6 +8,11 @@ bind:checked="$neverMarkMediaAsSensitive" on:change="onChange(event)"> {intl.showSensitive} +