From b445c15cc99a56c2baf727d05cf53b44aef4542b Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Sun, 12 Nov 2023 18:13:11 -0800 Subject: Refactor notifications to use react-query (#1878) * Move broadcast channel to lib * Refactor view/com/post/Post and remove temporary 2 components * Add useModerationOpts hook * Refactor notifications to use react-query * Fix: only trigger updates in useModerationOpts when the values have changed * Implement unread notification tracking * Add moderation filtering to notifications * Handle native/push notifications * Remove dead code --------- Co-authored-by: Eric Bailey --- src/view/com/posts/Feed.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/view/com/posts/Feed.tsx') diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx index 50afc1950..6cbad7f71 100644 --- a/src/view/com/posts/Feed.tsx +++ b/src/view/com/posts/Feed.tsx @@ -68,7 +68,7 @@ export function Feed({ const pal = usePalette('default') const theme = useTheme() const {track} = useAnalytics() - const [isRefreshing, setIsRefreshing] = React.useState(false) + const [isPTRing, setIsPTRing] = React.useState(false) const checkForNewRef = React.useRef<(() => void) | null>(null) const opts = React.useMemo(() => ({enabled}), [enabled]) @@ -137,15 +137,15 @@ export function Feed({ const onRefresh = React.useCallback(async () => { track('Feed:onRefresh') - setIsRefreshing(true) + setIsPTRing(true) try { await refetch() onHasNew?.(false) } catch (err) { logger.error('Failed to refresh posts feed', {error: err}) } - setIsRefreshing(false) - }, [refetch, track, setIsRefreshing, onHasNew]) + setIsPTRing(false) + }, [refetch, track, setIsPTRing, onHasNew]) const onEndReached = React.useCallback(async () => { if (isFetching || !hasNextPage || isError) return @@ -233,7 +233,7 @@ export function Feed({ ListHeaderComponent={ListHeaderComponent} refreshControl={