Skip to content

Commit

Permalink
Merge pull request #136 from deep-foundation/bugfix/contain_network_i…
Browse files Browse the repository at this point in the history
…n_device_instead_of_user

Bugfix/contain network in device instead of user
  • Loading branch information
FreePhoenix888 authored Sep 29, 2023
2 parents be75d74 + 275093e commit 09ca734
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/react/components/with-subscriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function WithSubscriptions({
isMotionSyncEnabled && <WithMotionSync deep={deep} containerLinkId={deviceLinkId}/>
}
{
isNetworkSyncEnabled && <NetworkStatus deep={deep} />
isNetworkSyncEnabled && <NetworkStatus deep={deep} containerLinkId={deviceLinkId} />
}
{
isGeolocationSyncEnabled && <WithPositionWatch containerLinkId={deviceLinkId} deep={deep}/>
Expand Down
77 changes: 44 additions & 33 deletions src/react/hooks/use-is-all-data-sync-enabled.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,52 @@
import { useLocalStore } from "@deep-foundation/store/local";
import { CapacitorStoreKeys } from "../../capacitor-store-keys";
import { packageLog } from "../../package-log";

export function useIsAllDataSyncEnabled() {
const log = packageLog.extend(useIsAllDataSyncEnabled.name);
const [isContactsSyncEnabled, setIsContactsSyncEnabled] = useLocalStore<
boolean | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.IsContactsSyncEnabled], undefined);
const [lastContactsSyncTime, setLastContactsSyncTime] = useLocalStore<
number | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.ContactsLastSyncTime], undefined);
const [isCallHistorySyncEnabled, setIsCallHistorySyncEnabled] = useLocalStore<
boolean | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.IsCallHistorySyncEnabled], undefined);
const [lastCallHistorySyncTime, setLastCallHistorySyncTime] = useLocalStore<
number | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.CallHistoryLastSyncTime], 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);
boolean | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.IsContactsSyncEnabled], undefined);
log({ isContactsSyncEnabled, setIsContactsSyncEnabled });
const [lastContactsSyncTime, setLastContactsSyncTime] = useLocalStore<
number | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.ContactsLastSyncTime], undefined);
log({ lastContactsSyncTime, setLastContactsSyncTime });
const [isCallHistorySyncEnabled, setIsCallHistorySyncEnabled] = useLocalStore<
boolean | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.IsCallHistorySyncEnabled], undefined);
log({ isCallHistorySyncEnabled, setIsCallHistorySyncEnabled });
const [lastCallHistorySyncTime, setLastCallHistorySyncTime] = useLocalStore<
number | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.CallHistoryLastSyncTime], undefined);
log({ lastCallHistorySyncTime, setLastCallHistorySyncTime });
const [isNetworkSyncEnabled, setIsNetworkSyncEnabled] = useLocalStore<
boolean | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.IsNetworkSubscriptionEnabled], false);
log({ isNetworkSyncEnabled, setIsNetworkSyncEnabled });
const [isVoiceRecorderEnabled, setIsVoiceRecorderEnabled] = useLocalStore<
boolean | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.IsVoiceRecorderEnabled], undefined);
log({ isVoiceRecorderEnabled, setIsVoiceRecorderEnabled });
const [isMotionSyncEnabled, setIsMotionSyncEnabled] = useLocalStore<
boolean | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.IsMotionSyncEnabled], undefined);
log({ isMotionSyncEnabled, setIsMotionSyncEnabled });
const [isGeolocationSyncEnabled, setIsGeolocationSyncEnabled] = useLocalStore<
boolean | undefined
>(CapacitorStoreKeys[CapacitorStoreKeys.IsGeolocationSyncEnabled], undefined);
log({ isGeolocationSyncEnabled, setIsGeolocationSyncEnabled });

const isAllDataSyncEnabled =
isContactsSyncEnabled &&
lastContactsSyncTime &&
isCallHistorySyncEnabled &&
lastCallHistorySyncTime &&
isNetworkSyncEnabled &&
isVoiceRecorderEnabled &&
isMotionSyncEnabled &&
isGeolocationSyncEnabled;
const isAllDataSyncEnabled =
isContactsSyncEnabled &&
lastContactsSyncTime &&
isCallHistorySyncEnabled &&
lastCallHistorySyncTime &&
isNetworkSyncEnabled &&
isVoiceRecorderEnabled &&
isMotionSyncEnabled &&
isGeolocationSyncEnabled;
log({ isAllDataSyncEnabled });

return isAllDataSyncEnabled;
}
}

0 comments on commit 09ca734

Please sign in to comment.