Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #2353, put 3 second limit on error notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb committed Apr 10, 2017
1 parent 96dfb69 commit 3bfd844
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions addon/webextension/background/senderror.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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]) {
Expand Down

0 comments on commit 3bfd844

Please sign in to comment.