Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Add soft reset to chat list (#7771)

* add soft reset to chat list

* refresh when soft resetting

authored by

Samuel Newman and committed by
GitHub
3409a725 595a8945

+26 -3
+26 -2
src/screens/Messages/ChatList.tsx
··· 1 1 import {useCallback, useEffect, useMemo, useState} from 'react' 2 2 import {View} from 'react-native' 3 + import {useAnimatedRef} from 'react-native-reanimated' 3 4 import {ChatBskyConvoDefs} from '@atproto/api' 4 5 import {msg, Trans} from '@lingui/macro' 5 6 import {useLingui} from '@lingui/react' 6 - import {useFocusEffect} from '@react-navigation/native' 7 + import {useFocusEffect, useIsFocused} from '@react-navigation/native' 7 8 import {NativeStackScreenProps} from '@react-navigation/native-stack' 8 9 9 10 import {useAppState} from '#/lib/hooks/useAppState' ··· 12 13 import {cleanError} from '#/lib/strings/errors' 13 14 import {logger} from '#/logger' 14 15 import {isNative} from '#/platform/detection' 16 + import {listenSoftReset} from '#/state/events' 15 17 import {MESSAGE_SCREEN_POLL_INTERVAL} from '#/state/messages/convo/const' 16 18 import {useMessagesEventBus} from '#/state/messages/events' 17 19 import {useLeftConvos} from '#/state/queries/messages/leave-conversation' 18 20 import {useListConvosQuery} from '#/state/queries/messages/list-conversations' 19 - import {List} from '#/view/com/util/List' 21 + import {List, ListRef} from '#/view/com/util/List' 20 22 import {atoms as a, useBreakpoints, useTheme, web} from '#/alf' 21 23 import {Button, ButtonIcon, ButtonText} from '#/components/Button' 22 24 import {DialogControlProps, useDialogControl} from '#/components/Dialog' ··· 48 50 const {_} = useLingui() 49 51 const t = useTheme() 50 52 const newChatControl = useDialogControl() 53 + const scrollElRef: ListRef = useAnimatedRef() 51 54 const pushToConversation = route.params?.pushToConversation 52 55 53 56 // Whenever we have `pushToConversation` set, it means we pressed a notification for a chat without being on ··· 134 137 [navigation], 135 138 ) 136 139 140 + const onSoftReset = useCallback(async () => { 141 + scrollElRef.current?.scrollToOffset({ 142 + animated: isNative, 143 + offset: 0, 144 + }) 145 + try { 146 + await refetch() 147 + } catch (err) { 148 + logger.error('Failed to refresh conversations', {message: err}) 149 + } 150 + }, [scrollElRef, refetch]) 151 + 152 + const isScreenFocused = useIsFocused() 153 + useEffect(() => { 154 + if (!isScreenFocused) { 155 + return 156 + } 157 + return listenSoftReset(onSoftReset) 158 + }, [onSoftReset, isScreenFocused]) 159 + 137 160 if (conversations.length < 1) { 138 161 return ( 139 162 <Layout.Screen> ··· 216 239 <Header newChatControl={newChatControl} /> 217 240 <NewChat onNewChat={onNewChat} control={newChatControl} /> 218 241 <List 242 + ref={scrollElRef} 219 243 data={conversations} 220 244 renderItem={renderItem} 221 245 keyExtractor={keyExtractor}
-1
src/view/com/notifications/NotificationFeed.tsx
··· 175 175 onEndReachedThreshold={2} 176 176 onScrolledDownChange={onScrolledDownChange} 177 177 contentContainerStyle={s.contentContainer} 178 - // @ts-ignore our .web version only -prf 179 178 desktopFixedHeight 180 179 initialNumToRender={initialNumToRender} 181 180 windowSize={11}