mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 00:56:23 +01:00
Add posting visibility setting
Also respect visibility setting when replying *if* replied-to post is public
This commit is contained in:
parent
470f7aa353
commit
6956628369
2 changed files with 67 additions and 1 deletions
|
@ -178,7 +178,11 @@ function Compose({
|
||||||
oninputTextarea();
|
oninputTextarea();
|
||||||
}
|
}
|
||||||
focusTextarea();
|
focusTextarea();
|
||||||
setVisibility(visibility);
|
setVisibility(
|
||||||
|
visibility === 'public' && prefs['posting:default:visibility']
|
||||||
|
? prefs['posting:default:visibility']
|
||||||
|
: visibility,
|
||||||
|
);
|
||||||
setLanguage(language || prefs.postingDefaultLanguage || DEFAULT_LANG);
|
setLanguage(language || prefs.postingDefaultLanguage || DEFAULT_LANG);
|
||||||
setSensitive(sensitive);
|
setSensitive(sensitive);
|
||||||
} else if (editStatus) {
|
} else if (editStatus) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import logo from '../assets/logo.svg';
|
||||||
import Icon from '../components/icon';
|
import Icon from '../components/icon';
|
||||||
import RelativeTime from '../components/relative-time';
|
import RelativeTime from '../components/relative-time';
|
||||||
import targetLanguages from '../data/lingva-target-languages';
|
import targetLanguages from '../data/lingva-target-languages';
|
||||||
|
import { api } from '../utils/api';
|
||||||
import getTranslateTargetLanguage from '../utils/get-translate-target-language';
|
import getTranslateTargetLanguage from '../utils/get-translate-target-language';
|
||||||
import localeCode2Text from '../utils/localeCode2Text';
|
import localeCode2Text from '../utils/localeCode2Text';
|
||||||
import states from '../utils/states';
|
import states from '../utils/states';
|
||||||
|
@ -25,6 +26,23 @@ function Settings({ onClose }) {
|
||||||
const systemTargetLanguageText = localeCode2Text(systemTargetLanguage);
|
const systemTargetLanguageText = localeCode2Text(systemTargetLanguage);
|
||||||
const currentTextSize = store.local.get('textSize') || DEFAULT_TEXT_SIZE;
|
const currentTextSize = store.local.get('textSize') || DEFAULT_TEXT_SIZE;
|
||||||
|
|
||||||
|
const [prefs, setPrefs] = useState(store.account.get('preferences') || {});
|
||||||
|
// Get preferences every time Settings is opened
|
||||||
|
// 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.
|
||||||
|
// useEffect(() => {
|
||||||
|
// const { masto } = api();
|
||||||
|
// (async () => {
|
||||||
|
// try {
|
||||||
|
// const preferences = await masto.v1.preferences.fetch();
|
||||||
|
// setPrefs(preferences);
|
||||||
|
// store.account.set('preferences', preferences);
|
||||||
|
// } catch (e) {
|
||||||
|
// // Silently fail
|
||||||
|
// console.error(e);
|
||||||
|
// }
|
||||||
|
// })();
|
||||||
|
// }, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="settings-container" class="sheet" tabIndex="-1">
|
<div id="settings-container" class="sheet" tabIndex="-1">
|
||||||
{!!onClose && (
|
{!!onClose && (
|
||||||
|
@ -144,6 +162,50 @@ function Settings({ onClose }) {
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
<h3>Posting</h3>
|
||||||
|
<section>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<div>
|
||||||
|
<label for="posting-privacy-field">Default visibility</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<select
|
||||||
|
id="posting-privacy-field"
|
||||||
|
value={prefs['posting:default:visibility'] || 'public'}
|
||||||
|
onChange={(e) => {
|
||||||
|
const { value } = e.target;
|
||||||
|
const { masto } = api();
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
await masto.v1.accounts.updateCredentials({
|
||||||
|
source: {
|
||||||
|
privacy: value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setPrefs({
|
||||||
|
...prefs,
|
||||||
|
'posting:default:visibility': value,
|
||||||
|
});
|
||||||
|
store.account.set('preferences', {
|
||||||
|
...prefs,
|
||||||
|
'posting:default:visibility': value,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
alert('Failed to update posting privacy');
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option value="public">Public</option>
|
||||||
|
<option value="unlisted">Unlisted</option>
|
||||||
|
<option value="private">Followers only</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
<h3>Experiments</h3>
|
<h3>Experiments</h3>
|
||||||
<section>
|
<section>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
Loading…
Reference in a new issue