From 85cd2d2cbcbcda5752ffde0ca2cc1db4998be878 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 21 Mar 2023 14:14:37 +0530 Subject: [PATCH] perf: Dont update list view data if list view not active (#20396) (#20419) Steps to reproduce: 1. visit a list view that's quite active 2. move to some other page 3. list view data keeps getting refreshed in background Fix: Only refresh when user is back on list view (cherry picked from commit 7fc6ae65aba13f277df98772f7ec65cea8c7e0cf) Co-authored-by: Ankush Menat --- frappe/public/js/frappe/list/list_view.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index de1292567f8..856625953a5 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -1309,6 +1309,13 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { process_document_refreshes() { if (!this.pending_document_refreshes.length) return; + const route = frappe.get_route() || []; + if (!cur_list || route[0] != "List" || cur_list.doctype != route[1]) { + // wait till user is back on list view before refreshing + this.pending_document_refreshes = []; + return; + } + const names = this.pending_document_refreshes.map((d) => d.name); this.pending_document_refreshes = this.pending_document_refreshes.filter( (d) => names.indexOf(d.name) === -1