fix: webclient still showing DM messages that had already been deleted from the server (#31537)
parent
c8ec364733
commit
4e138ea5b2
@ -0,0 +1,5 @@ |
||||
--- |
||||
'@rocket.chat/meteor': patch |
||||
--- |
||||
|
||||
Fixed an issue where the webclient didn't properly clear the message caches from memory when a room is deleted. When this happened to basic DMs and the user started a new DM with the same target user, the client would show the old messages in the room history even though they no longer existed in the server. |
||||
@ -0,0 +1,20 @@ |
||||
import { useStream } from '@rocket.chat/ui-contexts'; |
||||
import { useEffect } from 'react'; |
||||
|
||||
import { RoomHistoryManager } from '../../../../app/ui-utils/client'; |
||||
|
||||
export const useClearRemovedRoomsHistory = (userId: string | null) => { |
||||
const subscribeToNotifyUser = useStream('notify-user'); |
||||
|
||||
useEffect(() => { |
||||
if (!userId) { |
||||
return; |
||||
} |
||||
|
||||
return subscribeToNotifyUser(`${userId}/subscriptions-changed`, (event, data) => { |
||||
if (event === 'removed' && data.rid) { |
||||
RoomHistoryManager.clear(data.rid); |
||||
} |
||||
}); |
||||
}, [userId, subscribeToNotifyUser]); |
||||
}; |
||||
Loading…
Reference in new issue