Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_fetch: Fix load_messages called unexpectedly.

Aman Agrawal37d91d9759a3
diff --git a/web/src/message_fetch.ts b/web/src/message_fetch.ts
index 5fa9440f496..7d196da15b8 100644
--- a/web/src/message_fetch.ts
+++ b/web/src/message_fetch.ts
@@ -394,25 +394,22 @@ export function load_messages(opts: MessageFetchOptions, attempt = 1): void {
});
}
+ if (load_messages_timeout !== undefined) {
+ clearTimeout(load_messages_timeout);
+ }
+
void channel.get({
url: "/json/messages",
data,
success(raw_data) {
- if (load_messages_timeout !== undefined) {
- clearTimeout(load_messages_timeout);
- }
popup_banners.close_connection_error_popup_banner("message_fetch");
const data = response_schema.parse(raw_data);
get_messages_success(data, opts);
},
error(xhr) {
if (xhr.status === 400) {
- // We successfully reached the server, so hide the
- // connection error notice, even if the request failed
- // for other reasons.
- if (load_messages_timeout !== undefined) {
- clearTimeout(load_messages_timeout);
- }
+ // Even though the request failed, we did reach the
+ // server, and can hide the connection error notice.
popup_banners.close_connection_error_popup_banner("message_fetch");
}