Bluesky app fork with some witchin' additions 💫

Tune feed loading behavior (#528)

* Never autoload home feed on focus

* On web, just check for new notifications on focus

* Switching tab in the home feed now checks for latest

authored by

Paul Frazee and committed by
GitHub
f4da2f44 7a107627

+21 -17
+13 -14
src/view/screens/Home.tsx
··· 149 149 } 150 150 }, [isPageFocused, scrollToTop, feed]) 151 151 152 + // fires when screen is activated/deactivated 153 + // - set up polls/listeners, update content 152 154 useFocusEffect( 153 155 React.useCallback(() => { 154 156 const softResetSub = store.onScreenSoftReset(onSoftReset) ··· 168 170 } 169 171 }, [store, doPoll, onSoftReset, screen, feed]), 170 172 ) 173 + // fires when tab is actived/deactivated 174 + // - check for latest 171 175 useTabFocusEffect( 172 176 'Home', 173 177 React.useCallback( 174 178 isInside => { 175 - if (!isPageFocused) { 179 + if (!isPageFocused || !isInside) { 176 180 return 177 181 } 178 - // on mobile: 179 - // fires with `isInside=true` when the user navigates to the root tab 180 - // but not when the user goes back to the screen by pressing back 181 - // on web: 182 - // essentially equivalent to useFocusEffect because we dont used tabbed 183 - // navigation 184 - if (isInside) { 185 - if (feed.hasNewLatest) { 186 - feed.refresh() 187 - } else { 188 - feed.checkForLatest() 189 - } 190 - } 182 + feed.checkForLatest() 191 183 }, 192 184 [isPageFocused, feed], 193 185 ), 194 186 ) 187 + // fires when page within screen is activated/deactivated 188 + // - check for latest 189 + React.useEffect(() => { 190 + if (isPageFocused && isScreenFocused) { 191 + feed.checkForLatest() 192 + } 193 + }, [isPageFocused, isScreenFocused, feed]) 195 194 196 195 const onPressCompose = React.useCallback(() => { 197 196 track('HomeScreen:PressCompose')
+8 -3
src/view/screens/Notifications.tsx
··· 16 16 import {useTabFocusEffect} from 'lib/hooks/useTabFocusEffect' 17 17 import {s} from 'lib/styles' 18 18 import {useAnalytics} from 'lib/analytics' 19 + import {isWeb} from 'platform/detection' 19 20 20 21 type Props = NativeStackScreenProps< 21 22 NotificationsTabNavigatorParams, ··· 70 71 // essentially equivalent to useFocusEffect because we dont used tabbed 71 72 // navigation 72 73 if (isInside) { 73 - if (store.me.notifications.unreadCount > 0) { 74 - store.me.notifications.refresh() 74 + if (isWeb) { 75 + store.me.notifications.syncQueue() 75 76 } else { 76 - store.me.notifications.syncQueue() 77 + if (store.me.notifications.unreadCount > 0) { 78 + store.me.notifications.refresh() 79 + } else { 80 + store.me.notifications.syncQueue() 81 + } 77 82 } 78 83 } 79 84 },