mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-22 16:46:28 +01:00
Fix prefs bug
- Some prefs returned can be uppercased, so make them lowercase - `postingDefaultLanguage` probably doesn't work anymore every since masto.js upgrade. Sorry! - Add additional checks to make sure prefs from server are not in unexpected forms
This commit is contained in:
parent
3be53f1ff9
commit
78ca5bbc0b
3 changed files with 21 additions and 9 deletions
|
@ -289,10 +289,14 @@ function Compose({
|
|||
focusTextarea();
|
||||
setVisibility(
|
||||
visibility === 'public' && prefs['posting:default:visibility']
|
||||
? prefs['posting:default:visibility']
|
||||
? prefs['posting:default:visibility'].toLowerCase()
|
||||
: visibility,
|
||||
);
|
||||
setLanguage(language || prefs.postingDefaultLanguage || DEFAULT_LANG);
|
||||
setLanguage(
|
||||
language ||
|
||||
prefs['posting:default:language']?.toLowerCase() ||
|
||||
DEFAULT_LANG,
|
||||
);
|
||||
setSensitive(sensitive && !!spoilerText);
|
||||
} else if (editStatus) {
|
||||
const { visibility, language, sensitive, poll, mediaAttachments } =
|
||||
|
@ -316,7 +320,11 @@ function Compose({
|
|||
focusTextarea();
|
||||
spoilerTextRef.current.value = spoilerText;
|
||||
setVisibility(visibility);
|
||||
setLanguage(language || presf.postingDefaultLanguage || DEFAULT_LANG);
|
||||
setLanguage(
|
||||
language ||
|
||||
prefs['posting:default:language']?.toLowerCase() ||
|
||||
DEFAULT_LANG,
|
||||
);
|
||||
setSensitive(sensitive);
|
||||
if (composablePoll) setPoll(composablePoll);
|
||||
setMediaAttachments(mediaAttachments);
|
||||
|
@ -331,13 +339,13 @@ function Compose({
|
|||
focusTextarea();
|
||||
console.log('Apply prefs', prefs);
|
||||
if (prefs['posting:default:visibility']) {
|
||||
setVisibility(prefs['posting:default:visibility']);
|
||||
setVisibility(prefs['posting:default:visibility'].toLowerCase());
|
||||
}
|
||||
if (prefs['posting:default:language']) {
|
||||
setLanguage(prefs['posting:default:language']);
|
||||
setLanguage(prefs['posting:default:language'].toLowerCase());
|
||||
}
|
||||
if (prefs['posting:default:sensitive']) {
|
||||
setSensitive(prefs['posting:default:sensitive']);
|
||||
setSensitive(!!prefs['posting:default:sensitive']);
|
||||
}
|
||||
}
|
||||
if (draftStatus) {
|
||||
|
@ -360,7 +368,11 @@ function Compose({
|
|||
focusTextarea();
|
||||
if (spoilerText) spoilerTextRef.current.value = spoilerText;
|
||||
if (visibility) setVisibility(visibility);
|
||||
setLanguage(language || prefs.postingDefaultLanguage || DEFAULT_LANG);
|
||||
setLanguage(
|
||||
language ||
|
||||
prefs['posting:default:language']?.toLowerCase() ||
|
||||
DEFAULT_LANG,
|
||||
);
|
||||
if (sensitive !== null) setSensitive(sensitive);
|
||||
if (composablePoll) setPoll(composablePoll);
|
||||
if (mediaAttachments) setMediaAttachments(mediaAttachments);
|
||||
|
|
|
@ -108,7 +108,7 @@ function MediaPost({
|
|||
const readingExpandMedia = useMemo(() => {
|
||||
// default | show_all | hide_all
|
||||
const prefs = store.account.get('preferences') || {};
|
||||
return prefs['reading:expand:media'] || 'default';
|
||||
return prefs['reading:expand:media']?.toLowerCase() || 'default';
|
||||
}, []);
|
||||
const showSpoilerMedia = readingExpandMedia === 'show_all';
|
||||
|
||||
|
|
|
@ -407,7 +407,7 @@ function Status({
|
|||
// default | show_all | hide_all
|
||||
// Ignore hide_all because it means hide *ALL* media including non-sensitive ones
|
||||
const prefs = store.account.get('preferences') || {};
|
||||
return prefs['reading:expand:media'] || 'default';
|
||||
return prefs['reading:expand:media']?.toLowerCase() || 'default';
|
||||
}, []);
|
||||
// FOR TESTING:
|
||||
// const readingExpandSpoilers = true;
|
||||
|
|
Loading…
Reference in a new issue