Skip to content

Commit

Permalink
Revert "test: chat IntersectionObserver intersection time intersectio…
Browse files Browse the repository at this point in the history
…n 상태 사이 시간으로 변경"

This reverts commit 8a7a986.
  • Loading branch information
dia-triple committed Aug 28, 2023
1 parent 0f66d20 commit cd7cba9
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions packages/chat/src/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,26 @@ export const Chat = ({
if (isIntersecting) {
const prevScrollY = getChatListHeight()

const lastViewStartedAt = Number(
(target as HTMLElement).dataset.lastViewStartedAt || '',
)
if (
time - lastViewStartedAt >= MINIMUM_INTERSECTING_TIME &&
hasPrevMessage
) {
const pastMessages = await fetchPastMessages()
if (!(target as HTMLElement).dataset.viewStartedAt) {
;(target as HTMLElement).dataset.viewStartedAt = time.toString()
} else {
const viewStartedAt = Number(
(target as HTMLElement).dataset.viewStartedAt,
)
if (
time - viewStartedAt >= MINIMUM_INTERSECTING_TIME &&
hasPrevMessage
) {
const pastMessages = await fetchPastMessages()

await dispatch({
action: ChatActions.PAST,
messages: pastMessages,
})
setScrollY(prevScrollY)
await dispatch({
action: ChatActions.PAST,
messages: pastMessages,
})
setScrollY(prevScrollY)
}
}
}
;(target as HTMLElement).dataset.lastViewStartedAt = time.toString()
}

return (
Expand Down

0 comments on commit cd7cba9

Please sign in to comment.