mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix infinite query reloading behavior (reset, not invalidate) (#2031)

* Reset, not invalidate, notification queries

* Reset, not invalidate, feed queries

authored by

Paul Frazee and committed by
GitHub
4b3ec54a 9239efac

+13 -13
+2 -2
src/lib/notifications/notifications.ts
··· 83 83 ) 84 84 if (event.request.trigger.type === 'push') { 85 85 // refresh notifications in the background 86 - queryClient.invalidateQueries({queryKey: RQKEY_NOTIFS()}) 86 + queryClient.resetQueries({queryKey: RQKEY_NOTIFS()}) 87 87 // handle payload-based deeplinks 88 88 let payload 89 89 if (isIOS) { ··· 121 121 logger.DebugContext.notifications, 122 122 ) 123 123 track('Notificatons:OpenApp') 124 - queryClient.invalidateQueries({queryKey: RQKEY_NOTIFS()}) 124 + queryClient.resetQueries({queryKey: RQKEY_NOTIFS()}) 125 125 resetToTab('NotificationsTab') // open notifications tab 126 126 } 127 127 },
+1 -1
src/state/queries/notifications/unread.tsx
··· 126 126 // update & broadcast 127 127 setNumUnread(unreadCountStr) 128 128 if (invalidate) { 129 - queryClient.invalidateQueries({queryKey: RQKEY_NOTIFS()}) 129 + queryClient.resetQueries({queryKey: RQKEY_NOTIFS()}) 130 130 } 131 131 broadcast.postMessage({event: unreadCountStr}) 132 132 } catch (e) {
+2 -2
src/view/com/feeds/FeedPage.tsx
··· 62 62 const onSoftReset = React.useCallback(() => { 63 63 if (isPageFocused) { 64 64 scrollToTop() 65 - queryClient.invalidateQueries({queryKey: FEED_RQKEY(feed)}) 65 + queryClient.resetQueries({queryKey: FEED_RQKEY(feed)}) 66 66 setHasNew(false) 67 67 } 68 68 }, [isPageFocused, scrollToTop, queryClient, feed, setHasNew]) ··· 83 83 84 84 const onPressLoadLatest = React.useCallback(() => { 85 85 scrollToTop() 86 - queryClient.invalidateQueries({queryKey: FEED_RQKEY(feed)}) 86 + queryClient.resetQueries({queryKey: FEED_RQKEY(feed)}) 87 87 setHasNew(false) 88 88 }, [scrollToTop, feed, queryClient, setHasNew]) 89 89
+1 -1
src/view/screens/Notifications.tsx
··· 54 54 scrollToTop() 55 55 if (hasNew) { 56 56 // render what we have now 57 - queryClient.invalidateQueries({ 57 + queryClient.resetQueries({ 58 58 queryKey: NOTIFS_RQKEY(), 59 59 }) 60 60 } else {
+1 -1
src/view/screens/Profile.tsx
··· 403 403 404 404 const onScrollToTop = React.useCallback(() => { 405 405 scrollElRef.current?.scrollToOffset({offset: -headerHeight}) 406 - queryClient.invalidateQueries({queryKey: FEED_RQKEY(feed)}) 406 + queryClient.resetQueries({queryKey: FEED_RQKEY(feed)}) 407 407 setHasNew(false) 408 408 }, [scrollElRef, headerHeight, queryClient, feed, setHasNew]) 409 409 React.useImperativeHandle(ref, () => ({
+1 -1
src/view/screens/ProfileFeed.tsx
··· 501 501 502 502 const onScrollToTop = useCallback(() => { 503 503 scrollElRef.current?.scrollToOffset({offset: -headerHeight}) 504 - queryClient.invalidateQueries({queryKey: FEED_RQKEY(feed)}) 504 + queryClient.resetQueries({queryKey: FEED_RQKEY(feed)}) 505 505 setHasNew(false) 506 506 }, [scrollElRef, headerHeight, queryClient, feed, setHasNew]) 507 507
+2 -2
src/view/screens/ProfileList.tsx
··· 127 127 list, 128 128 onChange() { 129 129 if (isCurateList) { 130 - queryClient.invalidateQueries({ 130 + queryClient.resetQueries({ 131 131 // TODO(eric) should construct these strings with a fn too 132 132 queryKey: FEED_RQKEY(`list|${list.uri}`), 133 133 }) ··· 530 530 531 531 const onScrollToTop = useCallback(() => { 532 532 scrollElRef.current?.scrollToOffset({offset: -headerHeight}) 533 - queryClient.invalidateQueries({queryKey: FEED_RQKEY(feed)}) 533 + queryClient.resetQueries({queryKey: FEED_RQKEY(feed)}) 534 534 setHasNew(false) 535 535 }, [scrollElRef, headerHeight, queryClient, feed, setHasNew]) 536 536 React.useImperativeHandle(ref, () => ({
+1 -1
src/view/shell/Drawer.tsx
··· 141 141 } else { 142 142 if (tab === 'Notifications') { 143 143 // fetch new notifs on view 144 - queryClient.invalidateQueries({ 144 + queryClient.resetQueries({ 145 145 queryKey: NOTIFS_RQKEY(), 146 146 }) 147 147 }
+1 -1
src/view/shell/bottom-bar/BottomBar.tsx
··· 62 62 } else { 63 63 if (tab === 'Notifications') { 64 64 // fetch new notifs on view 65 - queryClient.invalidateQueries({ 65 + queryClient.resetQueries({ 66 66 queryKey: NOTIFS_RQKEY(), 67 67 }) 68 68 }
+1 -1
src/view/shell/desktop/LeftNav.tsx
··· 150 150 } else { 151 151 if (href === '/notifications') { 152 152 // fetch new notifs on view 153 - queryClient.invalidateQueries({ 153 + queryClient.resetQueries({ 154 154 queryKey: NOTIFS_RQKEY(), 155 155 }) 156 156 }