From 7a8893d8f690fa1bc9b3d743b2a43e777afc66ac Mon Sep 17 00:00:00 2001 From: MrQuackDuck Date: Fri, 3 Jan 2025 18:28:50 +0200 Subject: [PATCH] feat: add import/export of time format --- src/shared/lib/hooks/useImportExportSettings.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared/lib/hooks/useImportExportSettings.ts b/src/shared/lib/hooks/useImportExportSettings.ts index 000a051..f30b8a6 100644 --- a/src/shared/lib/hooks/useImportExportSettings.ts +++ b/src/shared/lib/hooks/useImportExportSettings.ts @@ -4,7 +4,7 @@ import Moment from "moment"; import { useContextSelector } from "use-context-selector"; import { UsersVolumeContext } from "@/features/control-user-volume"; -import { decryptString, encryptString } from "@/shared/lib"; +import { decryptString, encryptString, TimeFormatSettingsContext } from "@/shared/lib"; import { EncryptionKeysContext } from "../providers/EncryptionKeysProvider"; import { LanguageSettingsContext } from "../providers/LanguageSettingsProvider"; @@ -14,6 +14,7 @@ import { VoiceSettingsContext } from "../providers/VoiceSettingsProvider"; class Settings { currentLanguage: string; encryptionKeys: [string, string][]; + timeFormat: string; userVolumes: Record; isJoinLeaveSoundDisabled: boolean; isPingSoundDisabled: boolean; @@ -29,6 +30,7 @@ export const useImportExportSettings = () => { const { currentLanguage, setCurrentLanguage } = useContextSelector(LanguageSettingsContext, (c) => c); const userVolumes = useContextSelector(UsersVolumeContext, (c) => c.userVolumes); const { getAllEncryptionKeys, setEncryptionKey } = useContextSelector(EncryptionKeysContext, (c) => c); + const { timeFormat, setTimeFormat } = useContextSelector(TimeFormatSettingsContext, c => c); const { pingVolume, isPingSoundDisabled, setPingVolume, setIsPingSoundDisabled, joinLeaveVolume, isJoinLeaveSoundDisabled, setJoinLeaveVolume, setIsJoinLeaveSoundDisabled } = useContextSelector( NotificationsSettingsContext, @@ -50,6 +52,7 @@ export const useImportExportSettings = () => { const settings: Settings = { encryptionKeys: Array.from(getAllEncryptionKeys()!.entries()) ?? new Map(), currentLanguage, + timeFormat, userVolumes, isJoinLeaveSoundDisabled, isPingSoundDisabled, @@ -105,6 +108,7 @@ export const useImportExportSettings = () => { }); setCurrentLanguage(settings.currentLanguage); + setTimeFormat(settings.timeFormat as "12-hour" | "24-hour"); setIsJoinLeaveSoundDisabled(settings.isJoinLeaveSoundDisabled); setIsPingSoundDisabled(settings.isPingSoundDisabled); setJoinLeaveVolume(settings.joinLeaveVolume);