diff --git a/src/components/OtaUpdates/index.tsx b/src/components/OtaUpdates/index.tsx index b9941e3b..5bfbbe12 100644 --- a/src/components/OtaUpdates/index.tsx +++ b/src/components/OtaUpdates/index.tsx @@ -13,6 +13,8 @@ import Animated, { useSharedValue, useAnimatedStyle, withTiming } from 'react-na import DeviceInfo from 'react-native-device-info' import { OTA_UPDATE_ENABLED } from '../../configs/config' import { githubOTA, OTAUpdateManager, reloadApp, getStoredOtaVersion } from 'react-native-nitro-ota' +import { storage } from '../../constants/storage' +import { MMKVStorageKeys } from '../../enums/mmkv-storage-keys' const version = DeviceInfo.getVersion() @@ -27,6 +29,8 @@ const { downloadUrl, versionUrl } = githubOTA({ const otaVersion = getStoredOtaVersion() const isPRUpdate = otaVersion ? otaVersion.startsWith('PULL_REQUEST') : false +const isOTAUpdatesEnabled = storage.getBoolean(MMKVStorageKeys.IsOTAUpdatesEnabled) + const otaManager = new OTAUpdateManager(downloadUrl, versionUrl) export const downloadUpdate = (showCatchAlert: boolean = false) => { @@ -78,7 +82,7 @@ const GitUpdateModal = () => { } useEffect(() => { - if (__DEV__ || !OTA_UPDATE_ENABLED || isPRUpdate) { + if (__DEV__ || !OTA_UPDATE_ENABLED || isPRUpdate || !isOTAUpdatesEnabled) { return } onCheckGitVersion() diff --git a/src/enums/mmkv-storage-keys.ts b/src/enums/mmkv-storage-keys.ts index 0ed21388..c14da87a 100644 --- a/src/enums/mmkv-storage-keys.ts +++ b/src/enums/mmkv-storage-keys.ts @@ -25,4 +25,5 @@ export enum MMKVStorageKeys { ReducedHaptics = 'ReducedHaptics', Theme = 'Theme', SetupCompleted = 'SetupCompleted', + IsOTAUpdatesEnabled = 'IsOTAUpdatesEnabled', } diff --git a/src/screens/Setup/components/PrivacyStep.tsx b/src/screens/Setup/components/PrivacyStep.tsx index 6249ec0f..7d6a1211 100644 --- a/src/screens/Setup/components/PrivacyStep.tsx +++ b/src/screens/Setup/components/PrivacyStep.tsx @@ -13,9 +13,11 @@ import Animated, { withSequence, withTiming, } from 'react-native-reanimated' -import { useSendMetricsSetting } from '../../../stores/settings/app' +import { useDisableOTAUpdatesSetting, useSendMetricsSetting } from '../../../stores/settings/app' import MaterialDesignIcon from '@react-native-vector-icons/material-design-icons' import { useTheme } from 'tamagui' +import { useMMKVBoolean } from 'react-native-mmkv' +import { MMKVStorageKeys } from '../../../enums/mmkv-storage-keys' interface Props { onNext: () => void @@ -24,6 +26,9 @@ interface Props { export const PrivacyStep: React.FC = ({ onNext }) => { const [metrics, setMetrics] = useSendMetricsSetting() const theme = useTheme() + const [isOTAUpdatesEnabled, setIsOTAUpdatesEnabled] = useMMKVBoolean( + MMKVStorageKeys.IsOTAUpdatesEnabled, + ) const shieldScale = useSharedValue(1) const glowOpacity = useSharedValue(0.5) @@ -136,6 +141,35 @@ export const PrivacyStep: React.FC = ({ onNext }) => { + + + setIsOTAUpdatesEnabled(value)} + size='$4' + /> + + Enable OTA Updates to receive automatic updates. + + + + {/* Finish Button */} + void + sendMetrics: boolean setSendMetrics: (sendMetrics: boolean) => void @@ -34,6 +37,9 @@ export const useAppSettingsStore = create()( theme: 'system', setTheme: (theme: ThemeSetting) => set({ theme }), + + disableOTAUpdates: false, + setDisableOTAUpdates: (disableOTAUpdates: boolean) => set({ disableOTAUpdates }), }), { name: 'app-settings-storage', @@ -68,3 +74,11 @@ export const useSendMetricsSetting: () => [boolean, (sendMetrics: boolean) => vo export const useHideRunTimesSetting: () => [boolean, (hideRunTimes: boolean) => void] = () => useAppSettingsStore(useShallow((state) => [state.hideRunTimes, state.setHideRunTimes])) + +export const useDisableOTAUpdatesSetting: () => [ + boolean, + (disableOTAUpdates: boolean) => void, +] = () => + useAppSettingsStore( + useShallow((state) => [state.disableOTAUpdates, state.setDisableOTAUpdates]), + )