Skip to content

Commit

Permalink
test client
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Mar 13, 2024
1 parent 5d6f00c commit 6a8d10f
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/view/screens/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {View, ActivityIndicator, StyleSheet} from 'react-native'
import {View, ActivityIndicator, StyleSheet, Alert} from 'react-native'
import {useFocusEffect} from '@react-navigation/native'
import {NativeStackScreenProps, HomeTabNavigatorParams} from 'lib/routes/types'
import {FeedDescriptor, FeedParams} from '#/state/queries/post-feed'
Expand All @@ -18,6 +18,7 @@ import {emitSoftReset} from '#/state/events'
import {useSession} from '#/state/session'
import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed'
import {useSetTitle} from '#/lib/hooks/useSetTitle'
import * as Updates from 'expo-updates'

type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
export function HomeScreen(props: Props) {
Expand Down Expand Up @@ -61,6 +62,37 @@ function HomeScreenReady({
return feeds
}, [pinnedFeedInfos])

React.useEffect(() => {
;(async () => {
try {
const update = await Updates.checkForUpdateAsync()

if (update.isAvailable) {
Alert.alert(
'Update is available!',
'Do you want to install it now?',
[
{
text: 'Cancel',
style: 'cancel',
},
{
text: 'Install',
style: 'default',
onPress: async () => {
await Updates.fetchUpdateAsync()
await Updates.reloadAsync()
},
},
],
)
}
} catch (error) {
Alert.alert('Error', `${error}`)
}
})()
}, [])

const rawSelectedFeed = useSelectedFeed()
const setSelectedFeed = useSetSelectedFeed()
const maybeFoundIndex = allFeeds.indexOf(rawSelectedFeed as FeedDescriptor)
Expand Down

0 comments on commit 6a8d10f

Please sign in to comment.