mirror of
https://github.com/Qortal/chrome-extension.git
synced 2025-02-15 19:55:50 +00:00
change remove duplicate msgs
This commit is contained in:
parent
5433cf8e41
commit
5476ee3269
@ -149,7 +149,7 @@ const defaultValues: MyContextInterface = {
|
|||||||
message: "",
|
message: "",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
export let isMobile = true;
|
export let isMobile = false;
|
||||||
|
|
||||||
const isMobileDevice = () => {
|
const isMobileDevice = () => {
|
||||||
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
||||||
|
@ -255,7 +255,7 @@ export const AnnouncementDiscussion = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
height: isMobile ? '100%' : "100vh",
|
height: isMobile ? '100%' : "100%",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
@ -10,40 +10,35 @@ export const ChatList = ({ initialMessages, myAddress, tempMessages, chatId, onR
|
|||||||
const hasLoadedInitialRef = useRef(false);
|
const hasLoadedInitialRef = useRef(false);
|
||||||
const isAtBottomRef = useRef(true); //
|
const isAtBottomRef = useRef(true); //
|
||||||
// Update message list with unique signatures and tempMessages
|
// Update message list with unique signatures and tempMessages
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let uniqueInitialMessagesMap = new Map();
|
let uniqueInitialMessagesMap = new Map();
|
||||||
|
|
||||||
|
// Only add a message if it doesn't already exist in the Map
|
||||||
initialMessages.forEach((message) => {
|
initialMessages.forEach((message) => {
|
||||||
uniqueInitialMessagesMap.set(message.signature, message);
|
if (!uniqueInitialMessagesMap.has(message.signature)) {
|
||||||
|
uniqueInitialMessagesMap.set(message.signature, message);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const uniqueInitialMessages = Array.from(uniqueInitialMessagesMap.values()).sort(
|
const uniqueInitialMessages = Array.from(uniqueInitialMessagesMap.values()).sort(
|
||||||
(a, b) => a.timestamp - b.timestamp
|
(a, b) => a.timestamp - b.timestamp
|
||||||
);
|
);
|
||||||
const totalMessages = [...uniqueInitialMessages, ...(tempMessages || [])];
|
const totalMessages = [...uniqueInitialMessages, ...(tempMessages || [])];
|
||||||
|
|
||||||
if (totalMessages.length === 0) return;
|
if (totalMessages.length === 0) return;
|
||||||
|
|
||||||
setMessages(totalMessages);
|
setMessages(totalMessages);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const hasUnreadMessages = totalMessages.some((msg) => msg.unread && !msg?.chatReference);
|
const hasUnreadMessages = totalMessages.some((msg) => msg.unread && !msg?.chatReference);
|
||||||
|
|
||||||
if (virtuosoRef.current) {
|
if (virtuosoRef.current) {
|
||||||
|
|
||||||
|
|
||||||
if (virtuosoRef.current && !isAtBottomRef.current && hasUnreadMessages) {
|
if (virtuosoRef.current && !isAtBottomRef.current && hasUnreadMessages) {
|
||||||
|
setShowScrollButton(hasUnreadMessages);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setShowScrollButton(hasUnreadMessages);
|
|
||||||
} else {
|
} else {
|
||||||
handleMessageSeen();
|
handleMessageSeen();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!hasLoadedInitialRef.current) {
|
if (!hasLoadedInitialRef.current) {
|
||||||
scrollToBottom(totalMessages);
|
scrollToBottom(totalMessages);
|
||||||
@ -51,6 +46,7 @@ export const ChatList = ({ initialMessages, myAddress, tempMessages, chatId, onR
|
|||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}, [initialMessages, tempMessages]);
|
}, [initialMessages, tempMessages]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user