resolve issues with new features
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user