diff options
Diffstat (limited to 'src/screens/Messages/Conversation')
-rw-r--r-- | src/screens/Messages/Conversation/MessagesList.tsx | 18 | ||||
-rw-r--r-- | src/screens/Messages/Conversation/index.tsx | 14 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/screens/Messages/Conversation/MessagesList.tsx b/src/screens/Messages/Conversation/MessagesList.tsx index 5ba82eeff..dac534cd4 100644 --- a/src/screens/Messages/Conversation/MessagesList.tsx +++ b/src/screens/Messages/Conversation/MessagesList.tsx @@ -7,8 +7,8 @@ import {AppBskyRichtextFacet, RichText} from '@atproto/api' import {shortenLinks} from '#/lib/strings/rich-text-manip' import {isNative} from '#/platform/detection' -import {useConvo} from '#/state/messages/convo' -import {ConvoItem, ConvoStatus} from '#/state/messages/convo/types' +import {useConvoActive} from '#/state/messages/convo' +import {ConvoItem} from '#/state/messages/convo/types' import {useAgent} from '#/state/session' import {ScrollProvider} from 'lib/ScrollContext' import {isWeb} from 'platform/detection' @@ -60,7 +60,7 @@ function onScrollToIndexFailed() { } export function MessagesList() { - const convo = useConvo() + const convo = useConvoActive() const {getAgent} = useAgent() const flatListRef = useRef<FlatList>(null) @@ -128,7 +128,7 @@ export function MessagesList() { // The check for `hasInitiallyScrolled` prevents an initial fetch on mount. FlatList triggers `onStartReached` // immediately on mount, since we are in fact at an offset of zero, so we have to ignore those initial calls. const onStartReached = useCallback(() => { - if (convo.status === ConvoStatus.Ready && hasInitiallyScrolled.value) { + if (hasInitiallyScrolled.value) { convo.fetchMessageHistory() } }, [convo, hasInitiallyScrolled]) @@ -150,12 +150,10 @@ export function MessagesList() { return true }) - if (convo.status === ConvoStatus.Ready) { - convo.sendMessage({ - text: rt.text, - facets: rt.facets, - }) - } + convo.sendMessage({ + text: rt.text, + facets: rt.facets, + }) }, [convo, getAgent], ) diff --git a/src/screens/Messages/Conversation/index.tsx b/src/screens/Messages/Conversation/index.tsx index a783a0bd6..01c205ac8 100644 --- a/src/screens/Messages/Conversation/index.tsx +++ b/src/screens/Messages/Conversation/index.tsx @@ -15,7 +15,7 @@ import {useGate} from '#/lib/statsig/statsig' import {useCurrentConvoId} from '#/state/messages/current-convo-id' import {BACK_HITSLOP} from 'lib/constants' import {isIOS, isWeb} from 'platform/detection' -import {ConvoProvider, useConvo} from 'state/messages/convo' +import {ConvoProvider, isConvoActive, useConvo} from 'state/messages/convo' import {ConvoStatus} from 'state/messages/convo/types' import {PreviewableUserAvatar} from 'view/com/util/UserAvatar' import {CenteredView} from 'view/com/util/Views' @@ -72,14 +72,14 @@ function Inner() { React.useEffect(() => { if ( !hasInitiallyRendered && - convoState.status === ConvoStatus.Ready && + isConvoActive(convoState) && !convoState.isFetchingHistory ) { setTimeout(() => { setHasInitiallyRendered(true) }, 15) } - }, [convoState.isFetchingHistory, convoState.status, hasInitiallyRendered]) + }, [convoState, hasInitiallyRendered]) if (convoState.status === ConvoStatus.Error) { return ( @@ -108,10 +108,10 @@ function Inner() { <CenteredView style={a.flex_1} sideBorders> <Header profile={convoState.recipients?.[0]} /> <View style={[a.flex_1]}> - {convoState.status !== ConvoStatus.Ready ? ( - <ListMaybePlaceholder isLoading /> - ) : ( + {isConvoActive(convoState) ? ( <MessagesList /> + ) : ( + <ListMaybePlaceholder isLoading /> )} {!hasInitiallyRendered && ( <View @@ -230,7 +230,7 @@ let Header = ({ </> )} </View> - {convoState.status === ConvoStatus.Ready && profile ? ( + {isConvoActive(convoState) && profile ? ( <ConvoMenu convo={convoState.convo} profile={profile} |