1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-03 12:06:31 +02:00

Added notification display time.

Fixes #85.
This commit is contained in:
kkapsner 2016-11-11 00:19:25 +01:00
parent 410e92d1b0
commit d122f90655
6 changed files with 29 additions and 6 deletions

View file

@ -24,6 +24,9 @@
setShow: function(value){
prefs.showNotifications = value;
prefService.set("extensions.CanvasBlocker@kkapsner.de.showNotifications", prefs.showNotifications);
},
displayTime: function(){
return prefs.notificationDisplayTime;
}
};

View file

@ -7,6 +7,7 @@
var URL = require("sdk/url").URL;
const {parseErrorStack} = require("./callingStack");
const {setTimeout, clearTimeout} = require("sdk/timers");
var tabUtils = require("sdk/tabs/utils");
exports.notify = function({url, errorStack, messageId}, {lists, notificationPref, _, browser, window}){
@ -35,9 +36,7 @@ exports.notify = function({url, errorStack, messageId}, {lists, notificationPref
var notification = notifyBox.getNotificationWithValue("fake-readout");
if (notification){
notification.label = message;
notification.url = url;
notification.domain = domain;
notification.callingStackMsg = callingStackMsg;
clearTimeout(notification.hideTimeout);
}
else {
var buttons = [
@ -116,10 +115,17 @@ exports.notify = function({url, errorStack, messageId}, {lists, notificationPref
priority,
buttons
);
notification.url = url;
notification.domain = domain;
notification.callingStackMsg = callingStackMsg;
}
notification.url = url;
notification.domain = domain;
notification.callingStackMsg = callingStackMsg;
var displayTime = notificationPref.displayTime();
if (displayTime){
notification.hideTimeout = setTimeout(function(){
notification.close();
}, displayTime * 1000);
}
return notification;
}
};