1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Rewrite app start up procedure

This commit is contained in:
Zhiyuan Zheng
2020-12-28 23:20:18 +01:00
parent 7db153f2ae
commit 83b725b58d
4 changed files with 104 additions and 56 deletions

View File

@ -5,7 +5,7 @@ import {
NavigationContainerRef
} from '@react-navigation/native'
import React, { useEffect, useRef } from 'react'
import React, { useEffect, useRef, useState } from 'react'
import { StatusBar } from 'react-native'
import Toast from 'react-native-toast-message'
import { Feather } from '@expo/vector-icons'
@ -30,6 +30,7 @@ import {
import { useInfiniteQuery } from 'react-query'
import client from './api/client'
import { timelineFetch } from './utils/fetches/timelineFetch'
import { useNetInfo } from '@react-native-community/netinfo'
const Tab = createBottomTabNavigator<RootStackParamList>()
@ -55,6 +56,19 @@ export const Index: React.FC<Props> = ({ localCorrupt }) => {
dark = 'light-content'
}
const isConnected = useNetInfo().isConnected
const [firstRender, setFirstRender] = useState(false)
useEffect(() => {
if (firstRender) {
// bug in netInfo on first render as false
if (isConnected !== false) {
toast({ type: 'error', content: '手机🈚️网络', autoHide: false })
}
} else {
setFirstRender(true)
}
}, [isConnected, firstRender])
// On launch display login credentials corrupt information
useEffect(() => {
const showLocalCorrect = localCorrupt