From 70c31eae9e3d4346d5541d816e71c5448e5ec4d0 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Wed, 27 Nov 2024 10:21:53 -0800 Subject: [PATCH] feature/IO-3000-messaging-sockets-migration2 - - [EXISTING BUG?] The updated at timeframes do not automatically update as time passes. If you receive a message, and it is changed to a few seconds ago, if you wait a few minutes, it does not change unless you interact with it forcing a re-render. This can be solved by adding a tick state and periodically refreshing - unsure of the performance impact for many elements however. Signed-off-by: Dave Richer --- .../chat-conversation-list.component.jsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/src/components/chat-conversation-list/chat-conversation-list.component.jsx b/client/src/components/chat-conversation-list/chat-conversation-list.component.jsx index fe71ee46e..2aa11757d 100644 --- a/client/src/components/chat-conversation-list/chat-conversation-list.component.jsx +++ b/client/src/components/chat-conversation-list/chat-conversation-list.component.jsx @@ -1,5 +1,5 @@ import { Badge, Card, List, Space, Tag } from "antd"; -import React from "react"; +import React, { useEffect, useState } from "react"; import { connect } from "react-redux"; import { Virtuoso } from "react-virtuoso"; import { createStructuredSelector } from "reselect"; @@ -20,6 +20,18 @@ const mapDispatchToProps = (dispatch) => ({ }); function ChatConversationListComponent({ conversationList, selectedConversation, setSelectedConversation }) { + // That comma is there for a reason, do not remove it + const [, forceUpdate] = useState(false); + + // Re-render every minute + useEffect(() => { + const interval = setInterval(() => { + forceUpdate((prev) => !prev); // Toggle state to trigger re-render + }, 60000); // 1 minute in milliseconds + + return () => clearInterval(interval); // Cleanup on unmount + }, []); + const renderConversation = (index) => { const item = conversationList[index]; const cardContentRight = {item.updated_at};