Skip to content

Commit a625730

Browse files
authored
only show jump if loaded (#28431)
1 parent f63a1b0 commit a625730

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

shared/chat/conversation/list-area/hooks.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ export const useActions = (p: {conversationIDKey: T.Chat.ConversationIDKey}) =>
1919
}
2020

2121
export const useJumpToRecent = (scrollToBottom: () => void, numOrdinals: number) => {
22-
const containsLatestMessage = C.useChatContext(s => {
23-
return s.isCaughtUp()
24-
})
25-
const toggleThreadSearch = C.useChatContext(s => s.dispatch.toggleThreadSearch)
26-
const jumpToRecent = C.useChatContext(s => s.dispatch.jumpToRecent)
22+
const data = C.useChatContext(
23+
C.useShallow(s => {
24+
const containsLatestMessage = s.isCaughtUp()
25+
const {loaded} = s
26+
const {jumpToRecent, toggleThreadSearch} = s.dispatch
27+
return {containsLatestMessage, jumpToRecent, loaded, toggleThreadSearch}
28+
})
29+
)
30+
const {containsLatestMessage, jumpToRecent, loaded, toggleThreadSearch} = data
2731

2832
const onJump = React.useCallback(() => {
2933
scrollToBottom()
3034
jumpToRecent()
3135
toggleThreadSearch(true)
3236
}, [toggleThreadSearch, jumpToRecent, scrollToBottom])
3337

34-
return !containsLatestMessage && numOrdinals > 0 && <JumpToRecent onClick={onJump} />
38+
return loaded && !containsLatestMessage && numOrdinals > 0 && <JumpToRecent onClick={onJump} />
3539
}

0 commit comments

Comments
 (0)