From 88b07644eeb2db006ec5051ecdb2bc71f4fc5346 Mon Sep 17 00:00:00 2001 From: Phuoc Anh Kha Le <76896393+anhkha2003@users.noreply.github.com> Date: Wed, 3 Jan 2024 02:07:17 -0600 Subject: [PATCH] Fix chat bugs (#102) --- templates/chat/chat_css.html | 12 +++++++++--- templates/chat/chat_js.html | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/templates/chat/chat_css.html b/templates/chat/chat_css.html index ab9043d..41b9215 100644 --- a/templates/chat/chat_css.html +++ b/templates/chat/chat_css.html @@ -227,9 +227,15 @@ .active-span { display: none; } - #chat-area { - display: none; - } + {% if not room %} + #chat-area { + display: none; + } + {% else %} + .chat-left-panel { + display: none; + } + {% endif %} .back-button { margin-right: 1em; font-size: 1.5em; diff --git a/templates/chat/chat_js.html b/templates/chat/chat_js.html index 59cdf66..f09ca45 100644 --- a/templates/chat/chat_js.html +++ b/templates/chat/chat_js.html @@ -3,6 +3,7 @@ function load_next_page(last_id, refresh_html=false) { if (refresh_html) { + window.lock = true; $('#chat-log').html(''); $('#loader').show(); } @@ -13,11 +14,11 @@ $.get("{{ url('chat', '') }}" + window.room_id, param) .fail(function() { console.log("Fail to load page, last_id = " + last_id); + window.lock = false; }) .done(function(data) { if (refresh_html) { $('#chat-box').scrollTop($('#chat-box')[0].scrollHeight); - window.lock = true; } var time = refresh_html ? 0 : 200; @@ -67,7 +68,7 @@ } })} - function refresh_status() { + function refresh_status(refresh_chat_info=false) { $.get("{{url('online_status_ajax')}}") .fail(function() { console.log("Fail to get online status"); @@ -90,6 +91,10 @@ 'user': window.other_user_id, }; + if (refresh_chat_info) { + $('#chat-info').html(''); + } + $.get("{{url('user_online_status_ajax')}}", data) .fail(function() { console.log("Fail to get user online status"); @@ -299,7 +304,7 @@ history.replaceState(null, '', "{{url('chat', '')}}" + window.room_id); load_next_page(null, true); update_last_seen(); - refresh_status(); + refresh_status(true); $('#chat-input').focus(); show_right_panel(); }