Track spoilers

Turns out I'm using WeakMap wrong
This commit is contained in:
Lim Chee Aun 2022-12-20 19:14:50 +08:00
parent 7c5b0ccea3
commit 39efda9e38
2 changed files with 13 additions and 4 deletions

View file

@ -130,7 +130,7 @@ function Status({
}
}
const [showSpoiler, setShowSpoiler] = useState(false);
const showSpoiler = snapStates.spoilers.has(id) || false;
const debugHover = (e) => {
if (e.shiftKey) {
@ -293,7 +293,11 @@ function Status({
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setShowSpoiler(!showSpoiler);
if (showSpoiler) {
states.spoilers.delete(id);
} else {
states.spoilers.set(id, true);
}
}}
>
<Icon icon={showSpoiler ? 'eye-open' : 'eye-close'} />{' '}
@ -356,7 +360,11 @@ function Status({
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setShowSpoiler(!showSpoiler);
if (showSpoiler) {
states.spoilers.delete(id);
} else {
states.spoilers.add(id);
}
}}
>
<Icon icon={showSpoiler ? 'eye-open' : 'eye-close'} /> Sensitive

View file

@ -10,8 +10,9 @@ export default proxy({
notifications: [],
notificationsNew: [],
notificationsLastFetchTime: null,
accounts: new WeakMap(),
accounts: new Map(),
reloadStatusPage: 0,
spoilers: proxyMap([]),
// Modals
showCompose: false,
showSettings: false,