File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 44 */
55
66import { Ionicons } from '@expo/vector-icons' ;
7- import React from 'react' ;
7+ import React , { useEffect , useState } from 'react' ;
88import { StyleSheet , Text , View } from 'react-native' ;
99
1010import { useNetworkStatus } from '../services/network/networkManager' ;
@@ -13,6 +13,22 @@ import { useTheme } from '../theme';
1313export const OfflineIndicator : React . FC = ( ) => {
1414 const theme = useTheme ( ) ;
1515 const { isOnline } = useNetworkStatus ( ) ;
16+ const [ isReady , setIsReady ] = useState ( false ) ;
17+
18+ // Add 2-second grace period on mount to prevent flicker during app startup
19+ // Network status can be unstable during initialization
20+ useEffect ( ( ) => {
21+ const timer = setTimeout ( ( ) => {
22+ setIsReady ( true ) ;
23+ } , 2000 ) ; // 2 second grace period
24+
25+ return ( ) => clearTimeout ( timer ) ;
26+ } , [ ] ) ;
27+
28+ // Don't show until grace period is over
29+ if ( ! isReady ) {
30+ return null ;
31+ }
1632
1733 // Only show when offline
1834 if ( isOnline ) {
Original file line number Diff line number Diff line change @@ -114,11 +114,14 @@ export default function FoldersScreen() {
114114 const isFocused = useIsFocused ( ) ;
115115 const loadTimerRef = useRef < NodeJS . Timeout | null > ( null ) ;
116116 const isFirstMountRef = useRef ( true ) ;
117+ const hasDataRef = useRef ( false ) ;
117118
118119 // Load folders data
119120 const loadFoldersData = useCallback ( async ( isRefresh = false , forceRefresh = false ) => {
120121 try {
121- if ( ! isRefresh ) {
122+ // Only show loading state if we don't have data yet (first load)
123+ // On refocus, show existing data immediately and update in background (no flicker)
124+ if ( ! isRefresh && ! hasDataRef . current ) {
122125 setLoading ( true ) ;
123126 }
124127
@@ -156,6 +159,9 @@ export default function FoldersScreen() {
156159 } ;
157160
158161 setCounts ( newCounts ) ;
162+
163+ // Mark that we have data now (prevents loading state on refocus)
164+ hasDataRef . current = true ;
159165 } catch ( error ) {
160166 if ( __DEV__ ) console . error ( 'Failed to load folders data:' , error ) ;
161167 setAllFolders ( [ ] ) ;
You can’t perform that action at this time.
0 commit comments