()
| 271 | } |
| 272 | |
| 273 | function commitScrollState() { |
| 274 | const distanceFromBottom = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight; |
| 275 | pinnedRef.current = distanceFromBottom < 48; |
| 276 | const roundedScrollTop = Math.round(viewport.scrollTop / 12) * 12; |
| 277 | setScrollTop((current) => (current === roundedScrollTop ? current : roundedScrollTop)); |
| 278 | setViewportHeight((current) => (current === viewport.clientHeight ? current : viewport.clientHeight)); |
| 279 | setShowJumpButton((current) => (current === !pinnedRef.current ? current : !pinnedRef.current)); |
| 280 | if (pinnedRef.current) { |
| 281 | setHasQueuedNewerMessages((current) => (current ? false : current)); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | function updatePinnedState() { |
| 286 | if (scrollUpdateFrameRef.current !== null) { |
no outgoing calls
no test coverage detected