Respect 'reading:expand:spoilers' pref

Note this doesn't follow 'reading:expand:media' pref separately, so media will be spoiled too
pull/228/head
Lim Chee Aun 2023-09-14 11:22:24 +08:00
rodzic fa145d3ed0
commit fce5e45bc9
1 zmienionych plików z 12 dodań i 2 usunięć

Wyświetl plik

@ -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>
</>
)}