Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/ui.js

Issue 5256408131960832: Issue 2420 - Move notification show logic to core (Closed)
Patch Set: Address comments Created June 8, 2015, 7:31 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/notification.js ('K') | « lib/notification.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/ui.js
===================================================================
--- a/lib/ui.js
+++ b/lib/ui.js
@@ -419,10 +419,19 @@
this.updateState();
}.bind(this));
- notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- notificationTimer.initWithCallback(this.showNextNotification.bind(this),
- 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT);
- onShutdown.add(() => notificationTimer.cancel());
+ Notification.addShowListener(notification =>
+ {
+ let window = this.currentWindow;
+ if (!window)
+ return;
+
+ let button = window.document.getElementById("abp-toolbarbutton")
+ || window.document.getElementById("abp-status");
+ if (!button)
+ return;
+
+ this._showNotification(window, button, notification);
+ });
// Add "anti-adblock messages" notification
initAntiAdblockNotification();
@@ -433,7 +442,7 @@
if (!(subject instanceof Ci.nsIDOMWindow))
return;
- this.showNextNotification(subject.location.href);
+ Notification.showNext(subject.location.href);
}.bind(UI)
};
Services.obs.addObserver(documentCreationObserver, "content-document-global-created", false);
@@ -1849,24 +1858,6 @@
}
},
- showNextNotification: function(url)
- {
- let window = this.currentWindow;
- if (!window)
- return;
-
- let button = window.document.getElementById("abp-toolbarbutton")
- || window.document.getElementById("abp-status");
- if (!button)
- return;
-
- let notification = Notification.getNextToShow(url);
- if (!notification)
- return;
-
- this._showNotification(window, button, notification);
- },
-
_showNotification: function(window, button, notification)
{
let panel = window.document.getElementById("abp-notification");
@@ -1932,6 +1923,8 @@
window.document.getElementById("abp-notification-yes").onclick = buttonHandler.bind(null, true);
window.document.getElementById("abp-notification-no").onclick = buttonHandler.bind(null, false);
}
+ else
+ Notification.markAsShown(notification.id);
panel.setAttribute("class", "abp-" + notification.type);
panel.setAttribute("noautohide", notification.type === "question");
« lib/notification.js ('K') | « lib/notification.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld