From 5fe470e19562490d5b18414fef8836ea6623d805 Mon Sep 17 00:00:00 2001 From: GarboMuffin Date: Wed, 30 Aug 2023 13:40:47 -0500 Subject: [PATCH] local-storage: wait a few seconds between each namespace warning (#994) So if someone does this in a loop, for example, they wont be spammed with alerts forever Which matters especially in the desktop app as it won't give you an option to disable alerts for the site --- extensions/local-storage.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/local-storage.js b/extensions/local-storage.js index 2689b0e348..5e18ebc322 100644 --- a/extensions/local-storage.js +++ b/extensions/local-storage.js @@ -13,12 +13,15 @@ let namespace = ""; const getFullStorageKey = () => `${PREFIX}${namespace}`; + let lastNamespaceWarning = 0; + const validNamespace = () => { const valid = !!namespace; - if (!valid) { + if (!valid && Date.now() - lastNamespaceWarning > 3000) { alert( 'Local Storage extension: project must run the "set storage namespace ID" block before it can use other blocks' ); + lastNamespaceWarning = Date.now(); } return valid; };