resolve issues with new features

This commit is contained in:
Matthias Hochmeister
2026-03-12 18:36:22 +01:00
parent d1fed74f3b
commit 34f246af24
6 changed files with 30 additions and 23 deletions

View File

@@ -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 (