-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: webclient still showing DM messages that had already been delete…
…d from the server (#31537)
- Loading branch information
1 parent
c8ec364
commit 4e138ea
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
apps/meteor/client/providers/UserProvider/hooks/useClearRemovedRoomsHistory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]); | ||
}; |