Skip to content

Commit

Permalink
Use chat.messagesStatus instead of selector (#3087)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan committed Mar 23, 2023
1 parent 38d43c4 commit c9024ad
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/mobile/src/screens/chat-screen/ChatScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ export const ChatScreen = () => {
const itemsRef = useRef<(View | null)[]>([])
const composeRef = useRef<View | null>(null)
const unreadCount = chat?.unread_message_count ?? 0
const isLoading = status === Status.LOADING && chatMessages?.length === 0
const isLoading =
chat?.messagesStatus === Status.LOADING && chatMessages?.length === 0

// A ref so that the unread separator doesn't disappear immediately when the chat is marked as read
// Using a ref instead of state here to prevent unwanted flickers.
Expand Down Expand Up @@ -233,7 +234,7 @@ export const ChatScreen = () => {
const handleScrollToTop = () => {
if (
chatId &&
status !== Status.LOADING &&
chat?.messagesStatus !== Status.LOADING &&
chat?.messagesSummary &&
chat?.messagesSummary.prev_count > 0
) {
Expand Down Expand Up @@ -373,7 +374,7 @@ export const ChatScreen = () => {
initialNumToRender={chatMessages?.length}
ref={flatListRef}
onScrollToIndexFailed={handleScrollToIndexFailed}
refreshing={status === Status.LOADING}
refreshing={chat?.messagesStatus === Status.LOADING}
/>
</View>
) : (
Expand Down

0 comments on commit c9024ad

Please sign in to comment.