From 21d902c48c2ee499405b1e762f62e108f0636263 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 14 Mar 2021 20:30:44 +0300 Subject: [PATCH] deduplicate keys in prefs.subscribe --- js/prefs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/prefs.js b/js/prefs.js index 0d4986cd..0d1879dc 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -197,7 +197,8 @@ async subscribe(keys, fn, {runNow} = {}) { const toRun = []; if (keys) { - for (const key of Array.isArray(keys) ? keys : [keys]) { + const uniqKeys = new Set(Array.isArray(keys) ? keys : [keys]); + for (const key of uniqKeys) { if (!isKnown(key)) continue; const listeners = onChange.specific[key] || (onChange.specific[key] = new Set());