From 87be68d0748d0bb9d8c9f9f50d3a4fe3fb1a43a3 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 29 Sep 2023 11:45:36 +0600 Subject: [PATCH] Do not use setAllDataSync as hook --- src/set-all-data-sync.ts | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/set-all-data-sync.ts b/src/set-all-data-sync.ts index 732e5f6a..2fc61f3b 100644 --- a/src/set-all-data-sync.ts +++ b/src/set-all-data-sync.ts @@ -1,30 +1,16 @@ -import { useLocalStore } from "@deep-foundation/store/local"; import { CapacitorStoreKeys } from "./capacitor-store-keys"; export function setAllDataSync(toggle: boolean) { - const [isContactsSyncEnabled, setIsContactsSyncEnabled] = useLocalStore< - boolean | undefined ->(CapacitorStoreKeys[CapacitorStoreKeys.IsContactsSyncEnabled], undefined); -const [isCallHistorySyncEnabled, setIsCallHistorySyncEnabled] = useLocalStore< - boolean | undefined ->(CapacitorStoreKeys[CapacitorStoreKeys.IsCallHistorySyncEnabled], undefined); -const [isNetworkSyncEnabled, setIsNetworkSyncEnabled] = useLocalStore< - boolean | undefined ->(CapacitorStoreKeys[CapacitorStoreKeys.IsNetworkSubscriptionEnabled], false); -const [isVoiceRecorderEnabled, setIsVoiceRecorderEnabled] = useLocalStore< - boolean | undefined ->(CapacitorStoreKeys[CapacitorStoreKeys.IsVoiceRecorderEnabled], undefined); -const [isMotionSyncEnabled, setIsMotionSyncEnabled] = useLocalStore< - boolean | undefined ->(CapacitorStoreKeys[CapacitorStoreKeys.IsMotionSyncEnabled], undefined); -const [isGeolocationSyncEnabled, setIsGeolocationSyncEnabled] = useLocalStore< - boolean | undefined ->(CapacitorStoreKeys[CapacitorStoreKeys.IsGeolocationSyncEnabled], undefined); + const allKeys = [ + CapacitorStoreKeys.IsContactsSyncEnabled, + CapacitorStoreKeys.IsCallHistorySyncEnabled, + CapacitorStoreKeys.IsNetworkSubscriptionEnabled, + CapacitorStoreKeys.IsVoiceRecorderEnabled, + CapacitorStoreKeys.IsMotionSyncEnabled, + CapacitorStoreKeys.IsGeolocationSyncEnabled, + ]; -setIsContactsSyncEnabled(toggle); -setIsCallHistorySyncEnabled(toggle); -setIsNetworkSyncEnabled(toggle); -setIsVoiceRecorderEnabled(toggle); -setIsMotionSyncEnabled(toggle); -setIsGeolocationSyncEnabled(toggle); -} \ No newline at end of file + allKeys.forEach((key) => { + localStorage.setItem(CapacitorStoreKeys[key], JSON.stringify(toggle)); + }); +}