[🐴] Make status checks easier, fix load state (#4010)
* Make status checks easier, fix load state * Make naming more clear * Split up types for easier re-use * Replace hacky usage
This commit is contained in:
parent
bffb9b5906
commit
1c51a48764
6 changed files with 154 additions and 101 deletions
|
|
@ -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],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue