this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add posting visibility setting

Also respect visibility setting when replying *if* replied-to post is public

+67 -1
+5 -1
src/components/compose.jsx
··· 178 178 oninputTextarea(); 179 179 } 180 180 focusTextarea(); 181 - setVisibility(visibility); 181 + setVisibility( 182 + visibility === 'public' && prefs['posting:default:visibility'] 183 + ? prefs['posting:default:visibility'] 184 + : visibility, 185 + ); 182 186 setLanguage(language || prefs.postingDefaultLanguage || DEFAULT_LANG); 183 187 setSensitive(sensitive); 184 188 } else if (editStatus) {
+62
src/pages/settings.jsx
··· 7 7 import Icon from '../components/icon'; 8 8 import RelativeTime from '../components/relative-time'; 9 9 import targetLanguages from '../data/lingva-target-languages'; 10 + import { api } from '../utils/api'; 10 11 import getTranslateTargetLanguage from '../utils/get-translate-target-language'; 11 12 import localeCode2Text from '../utils/localeCode2Text'; 12 13 import states from '../utils/states'; ··· 24 25 const systemTargetLanguage = getTranslateTargetLanguage(); 25 26 const systemTargetLanguageText = localeCode2Text(systemTargetLanguage); 26 27 const currentTextSize = store.local.get('textSize') || DEFAULT_TEXT_SIZE; 28 + 29 + const [prefs, setPrefs] = useState(store.account.get('preferences') || {}); 30 + // Get preferences every time Settings is opened 31 + // 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. 32 + // useEffect(() => { 33 + // const { masto } = api(); 34 + // (async () => { 35 + // try { 36 + // const preferences = await masto.v1.preferences.fetch(); 37 + // setPrefs(preferences); 38 + // store.account.set('preferences', preferences); 39 + // } catch (e) { 40 + // // Silently fail 41 + // console.error(e); 42 + // } 43 + // })(); 44 + // }, []); 27 45 28 46 return ( 29 47 <div id="settings-container" class="sheet" tabIndex="-1"> ··· 140 158 <option value={size} /> 141 159 ))} 142 160 </datalist> 161 + </div> 162 + </li> 163 + </ul> 164 + </section> 165 + <h3>Posting</h3> 166 + <section> 167 + <ul> 168 + <li> 169 + <div> 170 + <label for="posting-privacy-field">Default visibility</label> 171 + </div> 172 + <div> 173 + <select 174 + id="posting-privacy-field" 175 + value={prefs['posting:default:visibility'] || 'public'} 176 + onChange={(e) => { 177 + const { value } = e.target; 178 + const { masto } = api(); 179 + (async () => { 180 + try { 181 + await masto.v1.accounts.updateCredentials({ 182 + source: { 183 + privacy: value, 184 + }, 185 + }); 186 + setPrefs({ 187 + ...prefs, 188 + 'posting:default:visibility': value, 189 + }); 190 + store.account.set('preferences', { 191 + ...prefs, 192 + 'posting:default:visibility': value, 193 + }); 194 + } catch (e) { 195 + alert('Failed to update posting privacy'); 196 + console.error(e); 197 + } 198 + })(); 199 + }} 200 + > 201 + <option value="public">Public</option> 202 + <option value="unlisted">Unlisted</option> 203 + <option value="private">Followers only</option> 204 + </select> 143 205 </div> 144 206 </li> 145 207 </ul>