resolve issues with new features
This commit is contained in:
@@ -49,16 +49,20 @@ const ChatPanelInner: React.FC = () => {
|
||||
// Mark unread rooms as read in Nextcloud whenever panel is open and rooms update
|
||||
React.useEffect(() => {
|
||||
if (!chatPanelOpen) return;
|
||||
rooms.filter((r) => r.unreadMessages > 0).forEach((r) => {
|
||||
nextcloudApi.markAsRead(r.token).catch(() => {});
|
||||
const unread = rooms.filter((r) => r.unreadMessages > 0);
|
||||
if (unread.length === 0) return;
|
||||
Promise.allSettled(unread.map((r) => nextcloudApi.markAsRead(r.token))).then(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ['nextcloud', 'rooms'] });
|
||||
});
|
||||
}, [chatPanelOpen, rooms]);
|
||||
}, [chatPanelOpen, rooms, queryClient]);
|
||||
|
||||
// Mark the selected room as read when a conversation is opened
|
||||
React.useEffect(() => {
|
||||
if (!selectedRoomToken) return;
|
||||
nextcloudApi.markAsRead(selectedRoomToken).catch(() => {});
|
||||
}, [selectedRoomToken]);
|
||||
nextcloudApi.markAsRead(selectedRoomToken).then(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ['nextcloud', 'rooms'] });
|
||||
}).catch(() => {});
|
||||
}, [selectedRoomToken, queryClient]);
|
||||
|
||||
if (!chatPanelOpen) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user