From fce5e45bc95225ff231b9dfdb4849f61492cb717 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun <cheeaun@gmail.com> Date: Thu, 14 Sep 2023 11:22:24 +0800 Subject: [PATCH] Respect 'reading:expand:spoilers' pref Note this doesn't follow 'reading:expand:media' pref separately, so media will be spoiled too --- src/components/status.jsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/status.jsx b/src/components/status.jsx index bc26d5fc..dc24b308 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -228,7 +228,12 @@ function Status({ inReplyToAccountId === currentAccount || mentions?.find((mention) => mention.id === currentAccount); - const showSpoiler = previewMode || !!snapStates.spoilers[id] || false; + const readingExpandSpoilers = useMemo(() => { + const prefs = store.account.get('preferences') || {}; + return !!prefs['reading:expand:spoilers']; + }, []); + const showSpoiler = + previewMode || readingExpandSpoilers || !!snapStates.spoilers[id] || false; if (reblog) { // If has statusID, means useItemID (cached in states) @@ -1128,6 +1133,7 @@ function Status({ <button class={`light spoiler ${showSpoiler ? 'spoiling' : ''}`} type="button" + disabled={readingExpandSpoilers} onClick={(e) => { e.preventDefault(); e.stopPropagation(); @@ -1139,7 +1145,11 @@ function Status({ }} > <Icon icon={showSpoiler ? 'eye-open' : 'eye-close'} />{' '} - {showSpoiler ? 'Show less' : 'Show more'} + {readingExpandSpoilers + ? 'Content warning' + : showSpoiler + ? 'Show less' + : 'Show more'} </button> </> )}