[Clipclops] External store, suspend/resume (#3829)
* Initial working external store * Clean up WIP, explore suspend/resume * Clean up state, bindings, snapshots, add some logs * Reduce snapshots, add better logic check * Bump interval a smidge * Remove unused type
This commit is contained in:
@@ -90,7 +90,9 @@ export function MessagesList() {
|
||||
}, [])
|
||||
|
||||
const onEndReached = useCallback(() => {
|
||||
chat.service.fetchMessageHistory()
|
||||
if (chat.status === ConvoStatus.Ready) {
|
||||
chat.fetchMessageHistory()
|
||||
}
|
||||
}, [chat])
|
||||
|
||||
const onInputFocus = useCallback(() => {
|
||||
@@ -103,11 +105,13 @@ export function MessagesList() {
|
||||
|
||||
const onSendMessage = useCallback(
|
||||
(text: string) => {
|
||||
chat.service.sendMessage({
|
||||
text,
|
||||
})
|
||||
if (chat.status === ConvoStatus.Ready) {
|
||||
chat.sendMessage({
|
||||
text,
|
||||
})
|
||||
}
|
||||
},
|
||||
[chat.service],
|
||||
[chat],
|
||||
)
|
||||
|
||||
const onScroll = React.useCallback(
|
||||
@@ -136,9 +140,7 @@ export function MessagesList() {
|
||||
contentContainerStyle={a.flex_1}>
|
||||
<FlatList
|
||||
ref={flatListRef}
|
||||
data={
|
||||
chat.state.status === ConvoStatus.Ready ? chat.state.items : undefined
|
||||
}
|
||||
data={chat.status === ConvoStatus.Ready ? chat.items : undefined}
|
||||
keyExtractor={keyExtractor}
|
||||
renderItem={renderItem}
|
||||
contentContainerStyle={{paddingHorizontal: 10}}
|
||||
@@ -161,8 +163,7 @@ export function MessagesList() {
|
||||
ListFooterComponent={
|
||||
<MaybeLoader
|
||||
isLoading={
|
||||
chat.state.status === ConvoStatus.Ready &&
|
||||
chat.state.isFetchingHistory
|
||||
chat.status === ConvoStatus.Ready && chat.isFetchingHistory
|
||||
}
|
||||
/>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user