Skip to content

Commit

Permalink
Merge pull request #134 from deep-foundation/bugfix/do_not_use_setAll…
Browse files Browse the repository at this point in the history
…DataSync_as_hook

Do not use setAllDataSync as hook
  • Loading branch information
FreePhoenix888 authored Sep 29, 2023
2 parents 5f33e7f + 87be68d commit be75d74
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions src/set-all-data-sync.ts
Original file line number Diff line number Diff line change
@@ -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);
}
allKeys.forEach((key) => {
localStorage.setItem(CapacitorStoreKeys[key], JSON.stringify(toggle));
});
}

0 comments on commit be75d74

Please sign in to comment.