Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Mar 21, 2024
1 parent 6e357c1 commit 4fa64c4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 71 deletions.
3 changes: 0 additions & 3 deletions app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ module.exports = function (config) {
const IS_DEV = process.env.EXPO_PUBLIC_ENV === 'development'
const IS_TESTFLIGHT = process.env.EXPO_PUBLIC_ENV === 'testflight'

// This will be changed later, but right now we only want to enable updates for testflight users
const IS_UPDATES_ENABLED = IS_TESTFLIGHT

const UPDATES_CHANNEL = IS_DEV
? 'development'
: IS_TESTFLIGHT
Expand Down
65 changes: 32 additions & 33 deletions src/App.native.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
import 'react-native-url-polyfill/auto'
import 'lib/sentry' // must be near top
import 'view/icons'

import React, {useState, useEffect} from 'react'
import {RootSiblingParent} from 'react-native-root-siblings'
import * as SplashScreen from 'expo-splash-screen'
import React, {useEffect, useState} from 'react'
import {GestureHandlerRootView} from 'react-native-gesture-handler'
import {PersistQueryClientProvider} from '@tanstack/react-query-persist-client'
import {RootSiblingParent} from 'react-native-root-siblings'
import {
SafeAreaProvider,
initialWindowMetrics,
SafeAreaProvider,
} from 'react-native-safe-area-context'
import * as SplashScreen from 'expo-splash-screen'
import {StatusBar} from 'expo-status-bar'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {PersistQueryClientProvider} from '@tanstack/react-query-persist-client'

import 'view/icons'

import {ThemeProvider as Alf} from '#/alf'
import {useColorModeTheme} from '#/alf/util/useColorModeTheme'
import {Provider as StatsigProvider} from '#/lib/statsig/statsig'
import {init as initPersistedState} from '#/state/persisted'
import {listenSessionDropped} from './state/events'
import {ThemeProvider} from 'lib/ThemeContext'
import {s} from 'lib/styles'
import {Shell} from 'view/shell'
import * as persisted from '#/state/persisted'
import {Provider as LabelDefsProvider} from '#/state/preferences/label-defs'
import {useIntentHandler} from 'lib/hooks/useIntentHandler'
import {useUpdateCheck} from 'lib/hooks/useUpdateCheck'
import * as notifications from 'lib/notifications/notifications'
import * as Toast from 'view/com/util/Toast'
import {
queryClient,
asyncStoragePersister,
dehydrateOptions,
queryClient,
} from 'lib/react-query'
import {TestCtrls} from 'view/com/testing/TestCtrls'
import {Provider as ShellStateProvider} from 'state/shell'
import {Provider as ModalStateProvider} from 'state/modals'
import {s} from 'lib/styles'
import {ThemeProvider} from 'lib/ThemeContext'
import {isAndroid} from 'platform/detection'
import {Provider as DialogStateProvider} from 'state/dialogs'
import {Provider as InvitesStateProvider} from 'state/invites'
import {Provider as LightboxStateProvider} from 'state/lightbox'
import {Provider as ModalStateProvider} from 'state/modals'
import {Provider as MutedThreadsProvider} from 'state/muted-threads'
import {Provider as InvitesStateProvider} from 'state/invites'
import {Provider as PrefsStateProvider} from 'state/preferences'
import {Provider as LoggedOutViewProvider} from 'state/shell/logged-out'
import {Provider as SelectedFeedProvider} from 'state/shell/selected-feed'
import {Provider as LabelDefsProvider} from '#/state/preferences/label-defs'
import I18nProvider from './locale/i18nProvider'
import {Provider as UnreadNotifsProvider} from 'state/queries/notifications/unread'
import {
Provider as SessionProvider,
useSession,
useSessionApi,
} from 'state/session'
import {Provider as UnreadNotifsProvider} from 'state/queries/notifications/unread'
import * as persisted from '#/state/persisted'
import {Splash} from '#/Splash'
import {Provider as ShellStateProvider} from 'state/shell'
import {Provider as LoggedOutViewProvider} from 'state/shell/logged-out'
import {Provider as SelectedFeedProvider} from 'state/shell/selected-feed'
import {TestCtrls} from 'view/com/testing/TestCtrls'
import * as Toast from 'view/com/util/Toast'
import {Shell} from 'view/shell'
import {ThemeProvider as Alf} from '#/alf'
import {useColorModeTheme} from '#/alf/util/useColorModeTheme'
import {Provider as PortalProvider} from '#/components/Portal'
import {Provider as StatsigProvider} from '#/lib/statsig/statsig'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useIntentHandler} from 'lib/hooks/useIntentHandler'
import {StatusBar} from 'expo-status-bar'
import {isAndroid} from 'platform/detection'
import {useUpdateCheck} from 'lib/hooks/useUpdateCheck'
import {Splash} from '#/Splash'
import I18nProvider from './locale/i18nProvider'
import {listenSessionDropped} from './state/events'

SplashScreen.preventAutoHideAsync()

Expand Down
67 changes: 32 additions & 35 deletions src/lib/hooks/useUpdateCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ export function useUpdateCheck() {
const setCheckTimeout = React.useCallback(() => {
timeout.current = setTimeout(async () => {
try {
Alert.alert('Try')
await Updates.setExtraParamAsync(
'buildNumber',
'build-number',
app.buildVersion.toString(),
)
Alert.alert('Here')
await Updates.setExtraParamAsync(
'channel',
IS_TESTFLIGHT ? 'testflight' : 'production',
Expand All @@ -47,39 +45,40 @@ export function useUpdateCheck() {

const onIsTestFlight = React.useCallback(() => {
setTimeout(async () => {
await Updates.setExtraParamAsync(
'buildNumber',
app.buildVersion.toString(),
)
await Updates.setExtraParamAsync(
'channel',
IS_TESTFLIGHT ? 'testflight' : 'production',
)
await Updates.setExtraParamAsync('build-number', app.buildVersion)
await Updates.setExtraParamAsync('channel', 'testflight')
await Updates.getExtraParamsAsync()

const res = await Updates.checkForUpdateAsync()
console.log(res)
if (res.isAvailable) {
await Updates.fetchUpdateAsync()
try {
const res = await Updates.checkForUpdateAsync()
if (res.isAvailable) {
await Updates.fetchUpdateAsync()

Alert.alert(
'Update Available',
'A new version of the app is available. Relaunch now?',
[
{
text: 'No',
style: 'cancel',
},
{
text: 'Relaunch',
style: 'default',
onPress: async () => {
await Updates.reloadAsync()
Alert.alert(
'Update Available',
'A new version of the app is available. Relaunch now?',
[
{
text: 'No',
style: 'cancel',
},
},
],
)
} else {
Alert.alert('No Update Available', 'No update available at this time.')
{
text: 'Relaunch',
style: 'default',
onPress: async () => {
await Updates.reloadAsync()
},
},
],
)
} else {
Alert.alert(
'No Update Available',
'No update available at this time.',
)
}
} catch (e: any) {
Alert.alert('error', e.toString())
}
}, 3000)
}, [])
Expand All @@ -94,8 +93,6 @@ export function useUpdateCheck() {
return
} else if (__DEV__ || ranInitialCheck.current) {
return
} else {
Alert.alert('not testfight')
}

setCheckTimeout()
Expand Down

0 comments on commit 4fa64c4

Please sign in to comment.