resolve issues with new features

This commit is contained in:
Matthias Hochmeister
2026-03-12 17:51:57 +01:00
parent 34ca007f9b
commit 67b7d5ccd2
10 changed files with 138 additions and 68 deletions

View File

@@ -37,30 +37,29 @@ const ChatPanelInner: React.FC = () => {
});
const nextcloudUrl = externalLinks?.nextcloud;
// Keep a ref to rooms so the effect can access the latest list without
// re-running every time room data refreshes.
const roomsRef = React.useRef(rooms);
roomsRef.current = rooms;
// Dismiss internal notifications when panel opens
React.useEffect(() => {
if (chatPanelOpen) {
// Dismiss our internal notification-centre entries
notificationsApi.dismissByType('nextcloud_talk').then(() => {
queryClient.invalidateQueries({ queryKey: ['notifications'] });
queryClient.invalidateQueries({ queryKey: ['unreadNotificationCount'] });
}).catch(() => {});
// Also mark all unread rooms as read directly in Nextcloud so that
// Nextcloud's own notification badges clear as well.
roomsRef.current
.filter((r) => r.unreadMessages > 0)
.forEach((r) => {
nextcloudApi.markAsRead(r.token).catch(() => {});
});
queryClient.invalidateQueries({ queryKey: ['nextcloud', 'rooms'] });
}
if (!chatPanelOpen) return;
notificationsApi.dismissByType('nextcloud_talk').then(() => {
queryClient.invalidateQueries({ queryKey: ['notifications'] });
queryClient.invalidateQueries({ queryKey: ['unreadNotificationCount'] });
}).catch(() => {});
}, [chatPanelOpen, queryClient]);
// 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(() => {});
});
}, [chatPanelOpen, rooms]);
// Mark the selected room as read when a conversation is opened
React.useEffect(() => {
if (!selectedRoomToken) return;
nextcloudApi.markAsRead(selectedRoomToken).catch(() => {});
}, [selectedRoomToken]);
if (!chatPanelOpen) {
return (
<Paper