From 09c6798a30d9a6076009cb30b02705dbc9343d2a Mon Sep 17 00:00:00 2001 From: Nelson Chan <3271800+chakflying@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:12:17 +0800 Subject: [PATCH] Fix: Add debounce to favicon update (#3442) --- src/mixins/socket.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mixins/socket.js b/src/mixins/socket.js index 2d27d109a..ebb908a9a 100644 --- a/src/mixins/socket.js +++ b/src/mixins/socket.js @@ -57,7 +57,8 @@ export default { message: "", errorMessage: "", currentPassword: "", - } + }, + faviconUpdateDebounce: null, }; }, @@ -760,7 +761,12 @@ export default { // Update Badge "stats.down"(to, from) { if (to !== from) { - favicon.badge(to); + if (this.faviconUpdateDebounce != null) { + clearTimeout(this.faviconUpdateDebounce); + } + this.faviconUpdateDebounce = setTimeout(() => { + favicon.badge(to); + }, 1000); } },