Skip to content

Commit

Permalink
perf: Dont update list view data if list view not active (#20396) (#2…
Browse files Browse the repository at this point in the history
…0419)

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 7fc6ae6)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed Mar 21, 2023
1 parent d2be9d7 commit 85cd2d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frappe/public/js/frappe/list/list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85cd2d2

Please sign in to comment.