feature/IO-3000-messaging-sockets-migration2 -

-misc

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-11-27 11:27:34 -08:00
parent 70c31eae9e
commit 8d6fba2b61
4 changed files with 95 additions and 136 deletions

View File

@@ -32,8 +32,13 @@ function ChatConversationListComponent({ conversationList, selectedConversation,
return () => clearInterval(interval); // Cleanup on unmount
}, []);
// Memoize the sorted conversation list
const sortedConversationList = React.useMemo(() => {
return _.orderBy(conversationList, ["updated_at"], ["desc"]);
}, [conversationList]);
const renderConversation = (index) => {
const item = conversationList[index];
const item = sortedConversationList[index];
const cardContentRight = <TimeAgoFormatter>{item.updated_at}</TimeAgoFormatter>;
const cardContentLeft =
item.job_conversations.length > 0
@@ -76,13 +81,10 @@ function ChatConversationListComponent({ conversationList, selectedConversation,
);
};
// CAN DO: Can go back into virtuoso for additional fetch
// endReached={loadMoreConversations} // Calls loadMoreConversations when scrolled to the bottom
return (
<div className="chat-list-container">
<Virtuoso
data={conversationList}
data={sortedConversationList}
itemContent={(index) => renderConversation(index)}
style={{ height: "100%", width: "100%" }}
/>