Skip to content

Commit d6501bf

Browse files
committed
Fixed a bug with previous clients receiving last messages whenever user opens up a new instance of chat.
1 parent 6c3e4e7 commit d6501bf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/app/chatroom/ChatRoomAPI.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11

22
export const subscribeChatRoom = (socketSubscribe, addMessage, chatRoomId) => {
3+
let alreadyFetchedLastMessages = false;
4+
35
socketSubscribe('/user/topic/chatroom/' + chatRoomId, {id: 'user-chatroom-' + chatRoomId}, (payload) => {
4-
handleMessageResponse(addMessage, payload, chatRoomId)
6+
if(!alreadyFetchedLastMessages){
7+
handleMessageResponse(addMessage, payload, chatRoomId);
8+
alreadyFetchedLastMessages = true;
9+
}
510
})
611

712
socketSubscribe('/topic/chatroom/' + chatRoomId, {id: 'chatroom-' + chatRoomId}, (payload) => {

0 commit comments

Comments
 (0)