From 3ee77c29a5d6c7199f8d827a124595aa51ea3ef9 Mon Sep 17 00:00:00 2001 From: Andrei Prigorshnev Date: Mon, 4 Sep 2023 17:00:09 +0400 Subject: [PATCH] DEV: no need to track status of a deleted user (#22836) It is hard to catch and debug potential bugs related to live updates of user status (though, we haven't seen many such bugs so far). We have a `console.warn` statement that should help us to catch one class of such bugs. Recently, we noticed that this warning gets printed when a user had a chat with a user that was then deleted. This is not a bug, since there is nothing to track for a deleted user, but we don't want this noise on the console. This PR makes sure we don't print a warning in such cases. --- .../javascripts/discourse/initializers/chat-sidebar.js | 5 ++++- plugins/chat/config/locales/client.en.yml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js index 24b7bf80a8e..c2dcb5e15ec 100644 --- a/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js +++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-sidebar.js @@ -210,7 +210,10 @@ export default { this.chatService = chatService; if (this.oneOnOneMessage) { - this.channel.chatable.users[0].trackStatus(); + const user = this.channel.chatable.users[0]; + if (user.username !== I18n.t("chat.deleted_chat_username")) { + user.trackStatus(); + } } } diff --git a/plugins/chat/config/locales/client.en.yml b/plugins/chat/config/locales/client.en.yml index e94052b4ae8..5d39b7b69d5 100644 --- a/plugins/chat/config/locales/client.en.yml +++ b/plugins/chat/config/locales/client.en.yml @@ -25,6 +25,7 @@ en: chat_users_count: "Chat Users" chat: + deleted_chat_username: deleted dates: time_tiny: "h:mm" all_loaded: "Showing all messages"