about summary refs log tree commit diff
path: root/src/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/view')
-rw-r--r--src/view/com/composer/Composer.tsx14
-rw-r--r--src/view/screens/Settings.tsx8
2 files changed, 12 insertions, 10 deletions
diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx
index e44a0ce01..a08992df4 100644
--- a/src/view/com/composer/Composer.tsx
+++ b/src/view/com/composer/Composer.tsx
@@ -49,6 +49,7 @@ import {LabelsBtn} from './labels/LabelsBtn'
 import {SelectLangBtn} from './select-language/SelectLangBtn'
 import {EmojiPickerButton} from './text-input/web/EmojiPicker.web'
 import {insertMentionAt} from 'lib/strings/mention-manip'
+import {useRequireAltTextEnabled} from '#/state/shell'
 
 type Props = ComposerOpts
 export const ComposePost = observer(function ComposePost({
@@ -61,6 +62,7 @@ export const ComposePost = observer(function ComposePost({
   const pal = usePalette('default')
   const {isDesktop, isMobile} = useWebMediaQueries()
   const store = useStores()
+  const requireAltTextEnabled = useRequireAltTextEnabled()
   const textInput = useRef<TextInputRef>(null)
   const [isKeyboardVisible] = useIsKeyboardVisible({iosUseWillEvents: true})
   const [isProcessing, setIsProcessing] = useState(false)
@@ -187,7 +189,7 @@ export const ComposePost = observer(function ComposePost({
     if (isProcessing || graphemeLength > MAX_GRAPHEME_LENGTH) {
       return
     }
-    if (store.preferences.requireAltTextEnabled && gallery.needsAltText) {
+    if (requireAltTextEnabled && gallery.needsAltText) {
       return
     }
 
@@ -241,12 +243,8 @@ export const ComposePost = observer(function ComposePost({
   const canPost = useMemo(
     () =>
       graphemeLength <= MAX_GRAPHEME_LENGTH &&
-      (!store.preferences.requireAltTextEnabled || !gallery.needsAltText),
-    [
-      graphemeLength,
-      store.preferences.requireAltTextEnabled,
-      gallery.needsAltText,
-    ],
+      (!requireAltTextEnabled || !gallery.needsAltText),
+    [graphemeLength, requireAltTextEnabled, gallery.needsAltText],
   )
   const selectTextInputPlaceholder = replyTo ? 'Write your reply' : `What's up?`
 
@@ -314,7 +312,7 @@ export const ComposePost = observer(function ComposePost({
             </>
           )}
         </View>
-        {store.preferences.requireAltTextEnabled && gallery.needsAltText && (
+        {requireAltTextEnabled && gallery.needsAltText && (
           <View style={[styles.reminderLine, pal.viewLight]}>
             <View style={styles.errorIcon}>
               <FontAwesomeIcon
diff --git a/src/view/screens/Settings.tsx b/src/view/screens/Settings.tsx
index ca4ef2a40..09a99e6d2 100644
--- a/src/view/screens/Settings.tsx
+++ b/src/view/screens/Settings.tsx
@@ -50,6 +50,8 @@ import {
   useSetMinimalShellMode,
   useColorMode,
   useSetColorMode,
+  useRequireAltTextEnabled,
+  useSetRequireAltTextEnabled,
 } from '#/state/shell'
 
 // TEMPORARY (APP-700)
@@ -66,6 +68,8 @@ export const SettingsScreen = withAuthRequired(
     const pal = usePalette('default')
     const store = useStores()
     const setMinimalShellMode = useSetMinimalShellMode()
+    const requireAltTextEnabled = useRequireAltTextEnabled()
+    const setRequireAltTextEnabled = useSetRequireAltTextEnabled()
     const navigation = useNavigation<NavigationProp>()
     const {isMobile} = useWebMediaQueries()
     const {screen, track} = useAnalytics()
@@ -372,8 +376,8 @@ export const SettingsScreen = withAuthRequired(
               type="default-light"
               label="Require alt text before posting"
               labelType="lg"
-              isSelected={store.preferences.requireAltTextEnabled}
-              onPress={store.preferences.toggleRequireAltTextEnabled}
+              isSelected={requireAltTextEnabled}
+              onPress={() => setRequireAltTextEnabled(!requireAltTextEnabled)}
             />
           </View>