feat: make settings typed and store "12" and "24" over "12-hour" and "24-hour" internally
This commit is contained in:
parent
eb49450756
commit
195322f3b0
5 changed files with 32 additions and 11 deletions
21
utils/settingsLoad.ts
Normal file
21
utils/settingsLoad.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import type { ClientSettings } from "~/types/settings"
|
||||
|
||||
export default (): ClientSettings => {
|
||||
let clientSettingsItem: string | null = localStorage.getItem("clientSettings")
|
||||
if (typeof clientSettingsItem != "string") {
|
||||
clientSettingsItem = "{}"
|
||||
}
|
||||
|
||||
let clientSettings: ClientSettings = {}
|
||||
try {
|
||||
clientSettings = JSON.parse(clientSettingsItem)
|
||||
} catch {
|
||||
clientSettings = {}
|
||||
}
|
||||
|
||||
if (typeof clientSettings !== "object") {
|
||||
clientSettings = {}
|
||||
}
|
||||
|
||||
return clientSettings
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue