fix: better sentinel
This commit is contained in:
parent
aff0007c23
commit
27b3451ad7
|
@ -23,7 +23,7 @@ export default function ChatMessages() {
|
|||
const {current} = $messages;
|
||||
const [, setIsAtBottom] = useState(true);
|
||||
const [outerHeight, setOuterHeight] = useState(0);
|
||||
const [scrollTop, setScrollTop] = useState(0);
|
||||
const [scrollTop, setScrollTop] = useState(-1);
|
||||
const [scrollHeight, setScrollHeight] = useState(Infinity);
|
||||
const messages = useSelector((state) => channelMessagesSelector(state, channel));
|
||||
const messageCount = messages && messages.length;
|
||||
|
@ -44,7 +44,7 @@ export default function ChatMessages() {
|
|||
useLayoutEffect(() => {
|
||||
const isAtBottom = !current
|
||||
? true
|
||||
: 0 === scrollTop || scrollTop + outerHeight >= scrollHeight;
|
||||
: -1 === scrollTop || scrollTop + outerHeight >= scrollHeight;
|
||||
setIsAtBottom(isAtBottom);
|
||||
if (isAtBottom) {
|
||||
current?.scrollTo(0, scrollHeight);
|
||||
|
|
Loading…
Reference in New Issue
Block a user