mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-23 19:37:52 +00:00
fix scrolldown when new msg
This commit is contained in:
parent
5cef7e9a70
commit
b8d715594e
@ -37,6 +37,7 @@ export const ChatList = ({
|
|||||||
|
|
||||||
const hasLoadedInitialRef = useRef(false);
|
const hasLoadedInitialRef = useRef(false);
|
||||||
const scrollingIntervalRef = useRef(null);
|
const scrollingIntervalRef = useRef(null);
|
||||||
|
const lastSeenUnreadMessageTimestamp = useRef(null);
|
||||||
|
|
||||||
|
|
||||||
// Initialize the virtualizer
|
// Initialize the virtualizer
|
||||||
@ -108,7 +109,7 @@ export const ChatList = ({
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const hasUnreadMessages = totalMessages.some(
|
const hasUnreadMessages = totalMessages.some(
|
||||||
(msg) => msg.unread && !msg?.chatReference && !msg?.isTemp
|
(msg) => msg.unread && !msg?.chatReference && !msg?.isTemp && (!msg?.chatReference && msg?.timestamp > lastSeenUnreadMessageTimestamp.current || 0)
|
||||||
);
|
);
|
||||||
if (parentRef.current) {
|
if (parentRef.current) {
|
||||||
const { scrollTop, scrollHeight, clientHeight } = parentRef.current;
|
const { scrollTop, scrollHeight, clientHeight } = parentRef.current;
|
||||||
@ -152,6 +153,7 @@ export const ChatList = ({
|
|||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
setShowScrollButton(false);
|
setShowScrollButton(false);
|
||||||
|
lastSeenUnreadMessageTimestamp.current = Date.now()
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const sentNewMessageGroupFunc = useCallback(() => {
|
const sentNewMessageGroupFunc = useCallback(() => {
|
||||||
@ -385,7 +387,7 @@ export const ChatList = ({
|
|||||||
Scroll to Unread Messages
|
Scroll to Unread Messages
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{showScrollDownButton && (
|
{showScrollDownButton && !showScrollButton && (
|
||||||
<button
|
<button
|
||||||
onClick={() => scrollToBottom()}
|
onClick={() => scrollToBottom()}
|
||||||
style={{
|
style={{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user