this repo has no description
0
fork

Configure Feed

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

Fix toggle values for settings for translation

+66 -55
+44 -35
src/pages/settings.jsx
··· 159 159 type="checkbox" 160 160 checked={snapStates.settings.contentTranslation} 161 161 onChange={(e) => { 162 - states.settings.contentTranslation = e.target.checked; 162 + const { checked } = e.target; 163 + states.settings.contentTranslation = checked; 164 + if (!checked) { 165 + states.settings.contentTranslationTargetLanguage = null; 166 + } 163 167 }} 164 168 />{' '} 165 169 Post translation 166 170 </label> 167 - {snapStates.settings.contentTranslation && ( 168 - <div class="sub-section"> 169 - <label> 170 - Translate to{' '} 171 - <select 172 - value={targetLanguage} 173 - onChange={(e) => { 174 - states.settings.contentTranslationTargetLanguage = 175 - e.target.value || null; 176 - }} 171 + <div 172 + class={`sub-section ${ 173 + !snapStates.settings.contentTranslation 174 + ? 'more-insignificant' 175 + : '' 176 + }`} 177 + > 178 + <label> 179 + Translate to{' '} 180 + <select 181 + value={targetLanguage || ''} 182 + disabled={!snapStates.settings.contentTranslation} 183 + onChange={(e) => { 184 + states.settings.contentTranslationTargetLanguage = 185 + e.target.value || null; 186 + }} 187 + > 188 + <option value=""> 189 + System language ({systemTargetLanguageText}) 190 + </option> 191 + <option disabled>──────────</option> 192 + {targetLanguages.map((lang) => ( 193 + <option value={lang.code}>{lang.name}</option> 194 + ))} 195 + </select> 196 + </label> 197 + <p> 198 + <small> 199 + Note: This feature uses an external API to translate, 200 + powered by{' '} 201 + <a 202 + href="https://github.com/thedaviddelta/lingva-translate" 203 + target="_blank" 177 204 > 178 - <option value=""> 179 - System language ({systemTargetLanguageText}) 180 - </option> 181 - <option disabled>──────────</option> 182 - {targetLanguages.map((lang) => ( 183 - <option value={lang.code}>{lang.name}</option> 184 - ))} 185 - </select> 186 - </label> 187 - <p> 188 - <small> 189 - Note: This feature uses an external API to translate, 190 - powered by{' '} 191 - <a 192 - href="https://github.com/thedaviddelta/lingva-translate" 193 - target="_blank" 194 - > 195 - Lingva Translate 196 - </a> 197 - . 198 - </small> 199 - </p> 200 - </div> 201 - )} 205 + Lingva Translate 206 + </a> 207 + . 208 + </small> 209 + </p> 210 + </div> 202 211 </li> 203 212 <li> 204 213 <button
+22 -20
src/utils/states.js
··· 56 56 console.log('CHANGE', v); 57 57 store.account.set('notificationsLast', states.notificationsLast); 58 58 }); 59 - subscribe(states, (v) => { 60 - console.debug('STATES change', v); 61 - const [action, path, value, prevValue] = v[0]; 62 - if (path.join('.') === 'settings.boostsCarousel') { 63 - store.account.set('settings-boostsCarousel', !!value); 64 - } 65 - if (path.join('.') === 'settings.shortcutsColumnsMode') { 66 - store.account.set('settings-shortcutsColumnsMode', !!value); 67 - } 68 - if (path.join('.') === 'settings.shortcutsViewMode') { 69 - store.account.set('settings-shortcutsViewMode', value); 70 - } 71 - if (path.join('.') === 'settings.contentTranslation') { 72 - store.account.set('settings-contentTranslation', !!value); 73 - } 74 - if (path.join('.') === 'settings.contentTranslationTargetLanguage') { 75 - store.account.set('settings-contentTranslationTargetLanguage', value); 76 - } 77 - if (path?.[0] === 'shortcuts') { 78 - store.account.set('shortcuts', states.shortcuts); 59 + subscribe(states, (changes) => { 60 + console.debug('STATES change', changes); 61 + for (const [action, path, value, prevValue] of changes) { 62 + if (path.join('.') === 'settings.boostsCarousel') { 63 + store.account.set('settings-boostsCarousel', !!value); 64 + } 65 + if (path.join('.') === 'settings.shortcutsColumnsMode') { 66 + store.account.set('settings-shortcutsColumnsMode', !!value); 67 + } 68 + if (path.join('.') === 'settings.shortcutsViewMode') { 69 + store.account.set('settings-shortcutsViewMode', value); 70 + } 71 + if (path.join('.') === 'settings.contentTranslation') { 72 + store.account.set('settings-contentTranslation', !!value); 73 + } 74 + if (path.join('.') === 'settings.contentTranslationTargetLanguage') { 75 + console.log('SET', value); 76 + store.account.set('settings-contentTranslationTargetLanguage', value); 77 + } 78 + if (path?.[0] === 'shortcuts') { 79 + store.account.set('shortcuts', states.shortcuts); 80 + } 79 81 } 80 82 }); 81 83