Skip to content

Commit

Permalink
local-storage: wait a few seconds between each namespace warning (#994)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
GarboMuffin authored Aug 30, 2023
1 parent 16f75eb commit 5fe470e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion extensions/local-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 5fe470e

Please sign in to comment.