···1515 useRef,
1616 useState,
1717} from 'preact/hooks';
1818-import punycode from 'punycode/';
1918import { useHotkeys } from 'react-hotkeys-hook';
2019import { useSearchParams } from 'react-router-dom';
2120import { uid } from 'uid/single';
···3029import NameText from '../components/name-text';
3130import NavMenu from '../components/nav-menu';
3231import RelativeTime from '../components/relative-time';
3333-import { api } from '../utils/api';
3232+import { api, getPreferences } from '../utils/api';
3433import { oklab2rgb, rgb2oklab } from '../utils/color-utils';
3534import db from '../utils/db';
3635import emojifyText from '../utils/emojify-text';
···18551854 const isThread =
18561855 (inReplyToId && inReplyToAccountId === account.id) || !!_thread;
1857185618581858- const readingExpandSpoilers = useMemo(() => {
18591859- const prefs = store.account.get('preferences') || {};
18601860- return !!prefs['reading:expand:spoilers'];
18611861- }, []);
18571857+ const prefs = getPreferences();
18581858+ const readingExpandSpoilers = !!prefs['reading:expand:spoilers'];
18621859 // const readingExpandSpoilers = true;
18631860 const showMedia =
18641861 readingExpandSpoilers ||
+3-3
src/pages/settings.jsx
···1111import Link from '../components/link';
1212import RelativeTime from '../components/relative-time';
1313import languages from '../data/translang-languages';
1414-import { api } from '../utils/api';
1414+import { api, getPreferences, setPreferences } from '../utils/api';
1515import getTranslateTargetLanguage from '../utils/get-translate-target-language';
1616import localeCode2Text from '../utils/localeCode2Text';
1717import prettyBytes from '../utils/pretty-bytes';
···5555 const systemTargetLanguageText = localeCode2Text(systemTargetLanguage);
5656 const currentTextSize = store.local.get('textSize') || DEFAULT_TEXT_SIZE;
57575858- const [prefs, setPrefs] = useState(store.account.get('preferences') || {});
5858+ const [prefs, setPrefs] = useState(getPreferences());
5959 const { masto, authenticated, instance } = api();
6060 // Get preferences every time Settings is opened
6161 // NOTE: Disabled for now because I don't expect this to change often. Also for some reason, the /api/v1/preferences endpoint is cached for a while and return old prefs if refresh immediately after changing them.
···300300 ...prefs,
301301 'posting:default:visibility': value,
302302 });
303303- store.account.set('preferences', {
303303+ setPreferences({
304304 ...prefs,
305305 'posting:default:visibility': value,
306306 });