Make "No Notifications" setting less broad, and fix a bug with default display behavior

Summary:
Fixes T12979. In D18457, we added a "No Notifications" setting to let users disable the blue and yellow pop-up notifications that alert you when an object has been updated, since some users found them distracting.

However, the change made "do nothing" the default, so all other `JX.Notification` callsites -- which never pass a preference -- were effectively turned off no matter what your setting was set to. This includes the "Read-Only" mode warning (grey), the "High Security" mode warning (purple), the "timezone" warning, and a few others.

Tweak things a little bit so the setting applies to ONLY blue and yellow ("object you're following was updated" / "this object was updated") notifications, not other types of popup notifications.

Test Plan:
  - With notifications on in settings, got blue notifications and "Read-only".
  - With notifications off in settings, got "Read-only" but no blue notifications.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T12979

Differential Revision: https://secure.phabricator.com/D18600
This commit is contained in:
epriestley
2017-09-13 14:51:34 -07:00
parent 6cedd4a95c
commit 29f625ef68
5 changed files with 42 additions and 56 deletions

View File

@@ -26,8 +26,7 @@ JX.install('Notification', {
_visible : false,
_hideTimer : null,
_duration : 12000,
_desktopReady : false,
_webReady : false,
_asDesktop : false,
_key : null,
_title : null,
_body : null,
@@ -37,11 +36,6 @@ JX.install('Notification', {
show : function() {
var self = JX.Notification;
// This person doesn't like any real-time notification
if (!this._desktopReady && !this._webReady) {
return;
}
if (!this._visible) {
this._visible = true;
@@ -51,7 +45,7 @@ JX.install('Notification', {
if (self.supportsDesktopNotifications() &&
self.desktopNotificationsEnabled() &&
this._desktopReady) {
this._asDesktop) {
// Note: specifying "tag" means that notifications with matching
// keys will aggregate.
var n = new window.Notification(this._title, {
@@ -94,13 +88,8 @@ JX.install('Notification', {
return this;
},
setDesktopReady : function(ready) {
this._desktopReady = ready;
return this;
},
setWebReady : function(ready) {
this._webReady = ready;
setShowAsDesktopNotification : function(mode) {
this._asDesktop = mode;
return this;
},