From 8cd7327d206a0cd31093ef58b4bb893f75bfe7f7 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Tue, 13 Aug 2024 17:57:05 +0700 Subject: [PATCH] Fix race condition in chat --- templates/chat/chat_js.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/chat/chat_js.html b/templates/chat/chat_js.html index e98517f..4180638 100644 --- a/templates/chat/chat_js.html +++ b/templates/chat/chat_js.html @@ -141,8 +141,11 @@ message: message, }, success: function (data) { - add_message(data); - callback(true); + // make sure user is still in the same room + if (room == window.room_id) { + add_message(data); + callback(true); + } }, error: function (data) { console.log('Could not add new message');