Skip to content

Commit

Permalink
feat(lib): add a better loader for chat
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-suwala committed Oct 16, 2023
1 parent b9bdcb8 commit d83e251
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function ChatScreen({}: StackScreenProps<HomeStackParamList, "Chat">) {
useContext(ChatContext)
const navigation = useNavigation()
const [isMoreMessages, setIsMoreMessages] = useState(true)
const [isLoadingMoreMessages, setIsLoadingMoreMessages] = useState(false)
const [isLoadingMoreMessages, setIsLoadingMoreMessages] = useState(true)
const [giftedChatMappedMessages, setGiftedChatMappedMessages] = useState<EnhancedIMessage[]>([])
const [typingData, setTypingData] = useState<string[]>([])
const [messageDraft, setMessageDraft] = useState<MessageDraft | null>(null)
Expand Down Expand Up @@ -155,6 +155,7 @@ export function ChatScreen({}: StackScreenProps<HomeStackParamList, "Chat">) {
if (!currentChannel) {
return
}
setIsLoadingMoreMessages(true)
setGiftedChatMappedMessages([])

const historicalMessagesObject = await currentChannel.getHistory({ count: 5 })
Expand Down Expand Up @@ -194,6 +195,8 @@ export function ChatScreen({}: StackScreenProps<HomeStackParamList, "Chat">) {
.reverse()
)
)

setIsLoadingMoreMessages(false)
}

switchChannelImplementation()
Expand Down

0 comments on commit d83e251

Please sign in to comment.