Fixes to feed load triggers (#2323)

* Add soft-reset support to ProfileFeed and ProfileList

* Fix: correctly unsubscribe the notifications soft-reset listener
This commit is contained in:
Paul Frazee 2023-12-27 08:53:24 -08:00 committed by GitHub
parent 8b6ecf6bff
commit e1ba649560
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View file

@ -1,6 +1,6 @@
import React from 'react'
import {View} from 'react-native'
import {useFocusEffect} from '@react-navigation/native'
import {useFocusEffect, useIsFocused} from '@react-navigation/native'
import {useQueryClient} from '@tanstack/react-query'
import {
NativeStackScreenProps,
@ -46,6 +46,7 @@ export function NotificationsScreen({}: Props) {
const unreadNotifs = useUnreadNotifications()
const unreadApi = useUnreadNotificationsApi()
const hasNew = !!unreadNotifs
const isScreenFocused = useIsFocused()
// event handlers
// =
@ -83,8 +84,11 @@ export function NotificationsScreen({}: Props) {
}, [screen, setMinimalShellMode]),
)
React.useEffect(() => {
if (!isScreenFocused) {
return
}
return listenSoftReset(onPressLoadLatest)
}, [onPressLoadLatest])
}, [onPressLoadLatest, isScreenFocused])
const ListHeaderComponent = React.useCallback(() => {
if (isDesktop) {