-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
140 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
import { getCompound, setCompound } from "../util/localStorage"; | ||
import { Config } from "./types"; | ||
import { reactive, watch } from "vue"; | ||
import { get, set } from "./localStorage"; | ||
import { AccessibilityConfig, AppConfig, SecurityConfig } from "./types"; | ||
import { updateAccessibility, updateDarkMode } from "../mode"; | ||
import { updateMaterialColors } from "../theme"; | ||
|
||
export const defaultConfig: Config = { | ||
app: { | ||
locale: { | ||
language: "en", | ||
firstWeekOfDayIsSunday: false, | ||
TwelveHourClock: false, | ||
}, | ||
view: "members", | ||
filterQueryMembers: "", | ||
filterQueryJournal: "" | ||
const defaultAppConfig: AppConfig = { | ||
locale: { | ||
language: "en", | ||
firstWeekOfDayIsSunday: false, | ||
twelveHourClock: false, | ||
}, | ||
accessibility: { | ||
highLegibility: false, | ||
highLegibilityType: "atkinson", | ||
theme: "auto", | ||
useAccentColor: false, | ||
accentColor: undefined, | ||
reducedMotion: false, | ||
fontScale: 1, | ||
chatFontScale: 1 | ||
}, | ||
security: { | ||
pinCode: undefined, | ||
useBiometrics: false | ||
} | ||
view: "members", | ||
filterQueryMembers: "", | ||
filterQueryJournal: "" | ||
}; | ||
|
||
export function getConfig(): Config { | ||
return Object.assign({}, defaultConfig, getCompound("config")); | ||
const defaultAccessibilityConfig: AccessibilityConfig = { | ||
highLegibility: false, | ||
highLegibilityType: "atkinson", | ||
theme: "auto", | ||
useAccentColor: false, | ||
accentColor: undefined, | ||
reducedMotion: false, | ||
fontScale: 1, | ||
chatFontScale: 1 | ||
} | ||
|
||
export function getConfigEntry(entryKey: keyof Config): Config[keyof Config] { | ||
return getConfig()[entryKey]; | ||
const defaultSecurityConfig: SecurityConfig = { | ||
usePin: false, | ||
pinCode: undefined, | ||
useBiometrics: false | ||
} | ||
|
||
export function saveConfig(config: Partial<Config>) { | ||
return setCompound("config", config); | ||
} | ||
export const appConfig = reactive<AppConfig>({...defaultAppConfig, ...get("appConfig") }); | ||
export const accessibilityConfig = reactive<AccessibilityConfig>({ ...defaultAccessibilityConfig, ...get("accessibilityConfig") }); | ||
export const securityConfig = reactive<SecurityConfig>({ ...defaultSecurityConfig, ...get("securityConfig") }); | ||
|
||
watch(appConfig, () => set("appConfig", {...appConfig})); | ||
watch(accessibilityConfig, () => { | ||
set("accessibilityConfig", { ...accessibilityConfig }); | ||
updateDarkMode(); | ||
updateMaterialColors(); | ||
updateAccessibility(); | ||
}); | ||
watch(securityConfig, () => set("securityConfig", { ...securityConfig })); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Typeson } from "typeson"; | ||
import { blob, file, filelist, map, typedArrays, undef, set as Tset, imagebitmap, imagedata } from "typeson-registry"; | ||
|
||
const typeson = new Typeson({ | ||
sync: true | ||
}).register([ | ||
file, | ||
filelist, | ||
blob, | ||
typedArrays, | ||
undef, | ||
map, | ||
Tset, | ||
imagebitmap, | ||
imagedata | ||
]); | ||
|
||
export function set(key: string, value: any){ | ||
return window.localStorage.setItem(key, JSON.stringify(typeson.encapsulate(value))); | ||
} | ||
|
||
export function get(key: string): any { | ||
const value = window.localStorage.getItem(key); | ||
|
||
try{ | ||
if (value !== "undefined" && value !== null) { | ||
const obj = JSON.parse(value); | ||
return typeson.revive(obj); | ||
} | ||
}catch(e){ | ||
console.error(e, value?.split("")); | ||
} | ||
|
||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.