From eab77f857dea961dc3b8fe445baebf391e42328c Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 21 Oct 2019 10:46:24 +0530 Subject: [PATCH] fix: Throttle clear cache --- frappe/public/js/frappe/ui/toolbar/toolbar.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/frappe/public/js/frappe/ui/toolbar/toolbar.js b/frappe/public/js/frappe/ui/toolbar/toolbar.js index 9bca9275b6..b98ef94887 100644 --- a/frappe/public/js/frappe/ui/toolbar/toolbar.js +++ b/frappe/public/js/frappe/ui/toolbar/toolbar.js @@ -225,19 +225,16 @@ $.extend(frappe.ui.toolbar, { }, }); -frappe.ui.toolbar.clear_cache = function() { +frappe.ui.toolbar.clear_cache = frappe.utils.throttle(function() { frappe.assets.clear_local_storage(); - frappe.call({ - method: 'frappe.sessions.clear', - callback: function(r) { - if(!r.exc) { - frappe.show_alert({message:r.message, indicator:'green'}); - location.reload(true); - } - } + frappe.xcall('frappe.sessions.clear').then(message => { + frappe.show_alert({ + message: message, + indicator: 'green' + }); + location.reload(true); }); - return false; -}; +}, 10000); frappe.ui.toolbar.show_about = function() { try {