Skip to content

Commit 4ffcdd4

Browse files
committed
fix(mobile): eliminate flickers, cache invalidation, and autocorrect
1 parent 9570c4d commit 4ffcdd4

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

apps/mobile/v1/src/components/OfflineIndicator.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { Ionicons } from '@expo/vector-icons';
7-
import React from 'react';
7+
import React, { useEffect, useState } from 'react';
88
import { StyleSheet, Text, View } from 'react-native';
99

1010
import { useNetworkStatus } from '../services/network/networkManager';
@@ -13,6 +13,22 @@ import { useTheme } from '../theme';
1313
export 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) {

apps/mobile/v1/src/screens/FoldersScreen.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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([]);

0 commit comments

Comments
 (0)