diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-06-02 15:01:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 15:01:04 -0500 |
commit | e8843ded5bf1f3d97b735ffe8f8553de46f9b18b (patch) | |
tree | 9c94613890fdc5428875dede148a5dd48e1c21a3 /src/state/models/ui/shell.ts | |
parent | 46c9de7c1865a57d2fef926db2d923a8687eca18 (diff) | |
download | voidsky-e8843ded5bf1f3d97b735ffe8f8553de46f9b18b.tar.zst |
Fix a bunch of type errors and add a type-check to the github workflows (#837)
* Add yarn type-check * Rename to yarn typecheck * Fix a collection of type errors * Add typecheck to automated tests * add `dist` to exluded folders tsconfig --------- Co-authored-by: Ansh Nanda <anshnanda10@gmail.com>
Diffstat (limited to 'src/state/models/ui/shell.ts')
-rw-r--r-- | src/state/models/ui/shell.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/state/models/ui/shell.ts b/src/state/models/ui/shell.ts index a77ffbdfb..3853f2395 100644 --- a/src/state/models/ui/shell.ts +++ b/src/state/models/ui/shell.ts @@ -8,6 +8,12 @@ import {ImageModel} from '../media/image' import {ListModel} from '../content/list' import {GalleryModel} from '../media/gallery' +export type ColorMode = 'system' | 'light' | 'dark' + +export function isColorMode(v: unknown): v is ColorMode { + return v === 'system' || v === 'light' || v === 'dark' +} + export interface ConfirmModal { name: 'confirm' title: string @@ -189,7 +195,7 @@ export interface ComposerOpts { } export class ShellUiModel { - colorMode = 'system' + colorMode: ColorMode = 'system' minimalShellMode = false isDrawerOpen = false isDrawerSwipeDisabled = false @@ -216,13 +222,13 @@ export class ShellUiModel { hydrate(v: unknown) { if (isObj(v)) { - if (hasProp(v, 'colorMode') && typeof v.colorMode === 'string') { + if (hasProp(v, 'colorMode') && isColorMode(v.colorMode)) { this.colorMode = v.colorMode } } } - setColorMode(mode: string) { + setColorMode(mode: ColorMode) { this.colorMode = mode } |