diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-12-27 08:53:24 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 08:53:24 -0800 |
commit | e1ba649560b9bb619dd445520ed9ea867f78ed4d (patch) | |
tree | 5378ced9ff6d236c15a0a02fa4609653296dfbc3 /src/view/screens/Notifications.tsx | |
parent | 8b6ecf6bfff0a18e92a172004cd37fe2aacaf37f (diff) | |
download | voidsky-e1ba649560b9bb619dd445520ed9ea867f78ed4d.tar.zst |
Fixes to feed load triggers (#2323)
* Add soft-reset support to ProfileFeed and ProfileList * Fix: correctly unsubscribe the notifications soft-reset listener
Diffstat (limited to 'src/view/screens/Notifications.tsx')
-rw-r--r-- | src/view/screens/Notifications.tsx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/view/screens/Notifications.tsx b/src/view/screens/Notifications.tsx index e28a67e37..6e2f18305 100644 --- a/src/view/screens/Notifications.tsx +++ b/src/view/screens/Notifications.tsx @@ -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) { |