From 3bfd844ce84c08850b20041c18ad6b3434c2463d Mon Sep 17 00:00:00 2001 From: Ian Bicking Date: Mon, 10 Apr 2017 10:10:55 -0500 Subject: [PATCH] Fix #2353, put 3 second limit on error notifications --- addon/webextension/background/senderror.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addon/webextension/background/senderror.js b/addon/webextension/background/senderror.js index 5be91451d4..68da0ed3aa 100644 --- a/addon/webextension/background/senderror.js +++ b/addon/webextension/background/senderror.js @@ -3,6 +3,9 @@ window.errorpopup = (function () { let exports = {}; + // Do not show an error more than every ERROR_TIME_LIMIT milliseconds: + const ERROR_TIME_LIMIT = 3000; + let messages = { REQUEST_ERROR: { title: browser.i18n.getMessage("requestErrorTitle"), @@ -41,7 +44,13 @@ window.errorpopup = (function () { catcher.unhandled(error); }); + let lastErrorTime; + exports.showError = function (error) { + if (lastErrorTime && (Date.now() - lastErrorTime) < ERROR_TIME_LIMIT) { + return; + } + lastErrorTime = Date.now(); let id = makeUuid(); let popupMessage = error.popupMessage || "generic"; if (! messages[popupMessage]) {