about summary refs log tree commit diff
path: root/src/state/models/ui
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-07-03 15:58:07 -0500
committerGitHub <noreply@github.com>2023-07-03 15:58:07 -0500
commit696bffe832c8ce748f2e4cc31e82764a6afb5b66 (patch)
tree1bcb67ea49bf66c9679aa369e9be3ea37b178f79 /src/state/models/ui
parentbc55241c9ae731f633f8b93a9b7eac7635070148 (diff)
downloadvoidsky-696bffe832c8ce748f2e4cc31e82764a6afb5b66.tar.zst
Add alt text validation option to user preferences (supersedes #913) (#914)
* Add alt text validation option to user preferences

* Fix typos/linting issues

* Update accessibility setting to match styles

* Update the required alt text reminder to go away once it's added

---------

Co-authored-by: Emma Fuller <emma@emmafuller.dev>
Diffstat (limited to 'src/state/models/ui')
-rw-r--r--src/state/models/ui/preferences.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/state/models/ui/preferences.ts b/src/state/models/ui/preferences.ts
index 28c7c5666..858225a6f 100644
--- a/src/state/models/ui/preferences.ts
+++ b/src/state/models/ui/preferences.ts
@@ -53,6 +53,7 @@ export class PreferencesModel {
   homeFeedRepliesThreshold: number = 2
   homeFeedRepostsEnabled: boolean = true
   homeFeedQuotePostsEnabled: boolean = true
+  requireAltTextEnabled: boolean = false
 
   // used to linearize async modifications to state
   lock = new AwaitLock()
@@ -72,6 +73,7 @@ export class PreferencesModel {
       homeFeedRepliesThreshold: this.homeFeedRepliesThreshold,
       homeFeedRepostsEnabled: this.homeFeedRepostsEnabled,
       homeFeedQuotePostsEnabled: this.homeFeedQuotePostsEnabled,
+      requireAltTextEnabled: this.requireAltTextEnabled,
     }
   }
 
@@ -152,6 +154,13 @@ export class PreferencesModel {
       ) {
         this.homeFeedQuotePostsEnabled = v.homeFeedQuotePostsEnabled
       }
+      // check if requiring alt text is enabled in preferences, then hydrate
+      if (
+        hasProp(v, 'requireAltTextEnabled') &&
+        typeof v.requireAltTextEnabled === 'boolean'
+      ) {
+        this.requireAltTextEnabled = v.requireAltTextEnabled
+      }
     }
   }
 
@@ -467,4 +476,8 @@ export class PreferencesModel {
   toggleHomeFeedQuotePostsEnabled() {
     this.homeFeedQuotePostsEnabled = !this.homeFeedQuotePostsEnabled
   }
+
+  toggleRequireAltTextEnabled() {
+    this.requireAltTextEnabled = !this.requireAltTextEnabled
+  }
 }