diff options
author | Hailey <me@haileyok.com> | 2024-05-28 18:15:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 02:15:35 +0100 |
commit | 888bec7b4fbe1b924d788333ec44c916fd3e8676 (patch) | |
tree | a301b8dd200c3252f925bca0bab242e9bad230c1 /src/lib/hooks | |
parent | 5ceb440d4e46a69747316836626a6abcf7246ca1 (diff) | |
download | voidsky-888bec7b4fbe1b924d788333ec44c916fd3e8676.tar.zst |
Upgrade to Expo 51 and React Native 0.74 (#3980)
* upgrade packages * remove `expo-image-picker` patch * remove old expo-updates patch * rename rn patch * downgrade crop picker * bump `ExpoGifView` `SDWebImage` version * apply config changes * update build docs for apple silicon * update build docs for apple silicon * update expo-updates patch * add back patch readme * bump `expo-dev-client` * bump `babel-preset` * update `babel.config.js` * update `react-native-paste-input` patch * remove old ota updates hook * update types * update types * downgrade pager-view * update animated ref type * fix web-only type * update `react-native-bottom-sheet` `BottomSheetTextInput` * add `expo-application` to jest mocks * remove reanimated patch * update notifications patch * update reanimated path * fix import * update yarn.lock * use `ItemT` instead of `any` * expo bump * Revert logic change, fix types * Fix JSON file --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src/lib/hooks')
-rw-r--r-- | src/lib/hooks/useOTAUpdate.ts | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/src/lib/hooks/useOTAUpdate.ts b/src/lib/hooks/useOTAUpdate.ts deleted file mode 100644 index d35179256..000000000 --- a/src/lib/hooks/useOTAUpdate.ts +++ /dev/null @@ -1,56 +0,0 @@ -import * as Updates from 'expo-updates' -import {useCallback, useEffect} from 'react' -import {AppState} from 'react-native' -import {logger} from '#/logger' - -export function useOTAUpdate() { - // HELPER FUNCTIONS - const checkForUpdate = useCallback(async () => { - logger.debug('useOTAUpdate: Checking for update...') - try { - // Check if new OTA update is available - const update = await Updates.checkForUpdateAsync() - // If updates aren't available stop the function execution - if (!update.isAvailable) { - return - } - // Otherwise fetch the update in the background, so even if the user rejects switching to latest version it will be done automatically on next relaunch. - await Updates.fetchUpdateAsync() - } catch (e) { - logger.error('useOTAUpdate: Error while checking for update', { - message: e, - }) - } - }, []) - const updateEventListener = useCallback((event: Updates.UpdateEvent) => { - logger.debug('useOTAUpdate: Listening for update...') - if (event.type === Updates.UpdateEventType.ERROR) { - logger.error('useOTAUpdate: Error while listening for update', { - message: event.message, - }) - } else if (event.type === Updates.UpdateEventType.NO_UPDATE_AVAILABLE) { - // Handle no update available - // do nothing - } else if (event.type === Updates.UpdateEventType.UPDATE_AVAILABLE) { - // Handle update available - // open modal, ask for user confirmation, and reload the app - } - }, []) - - useEffect(() => { - // ADD EVENT LISTENERS - const updateEventSubscription = Updates.addListener(updateEventListener) - const appStateSubscription = AppState.addEventListener('change', state => { - if (state === 'active' && !__DEV__) { - checkForUpdate() - } - }) - - // REMOVE EVENT LISTENERS (CLEANUP) - return () => { - updateEventSubscription.remove() - appStateSubscription.remove() - } - }, []) // eslint-disable-line react-hooks/exhaustive-deps - // disable exhaustive deps because we don't want to run this effect again -} |