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.

gifs: Prevent stale network calls beacuse of debouncing.

apoorvapendseb761e843087c
diff --git a/web/src/gif_picker_ui.ts b/web/src/gif_picker_ui.ts
index 7326bdcc9d4..75245257473 100644
--- a/web/src/gif_picker_ui.ts
+++ b/web/src/gif_picker_ui.ts
@@ -148,6 +148,11 @@ function render_featured_gifs(next_page: boolean): void {
}
function update_grid_with_search_term(search_term: string, next_page = false): void {
+ // The debounced version may call this after the picker is closed
+ // and the cleanup is done, so we add this guard.
+ if (popover_instance === undefined) {
+ return;
+ }
if (
network.is_loading_more_gifs() ||
(search_term.trim() === current_search_term && !next_page)