1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Correct the behavior of "Desktop Only" in Notifications preferences

Summary:
See <https://discourse.phabricator-community.org/t/desktop-only-notifications-mode-is-broken/1234>. Ref T13102. The "Desktop Only" mode for notifications currently shows both desktop and web notifications.

In fact, `JX.Notification` currently has no ability to render notifications as desktop-only. Make this work.

Note that many of the variables and parameters here, including `showAnyNotification`, `web_ready`, and `desktop_ready`, are named in an incorrect or misleading way. However, the new behavior appears to be correct.

Test Plan:
  - Emitted test notifications in "No Notifications", "Web Only", "Web and Desktop", and "Desktop" modes.
  - Saw appropriate notifications appear in the UI.

Maniphest Tasks: T13102

Differential Revision: https://secure.phabricator.com/D19233
This commit is contained in:
epriestley 2018-03-16 15:10:26 -07:00
parent fa6cd200e8
commit dbc72a05bc
3 changed files with 41 additions and 27 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => 'e68cf1fa', 'conpherence.pkg.css' => 'e68cf1fa',
'conpherence.pkg.js' => '15191c65', 'conpherence.pkg.js' => '15191c65',
'core.pkg.css' => 'c218ed53', 'core.pkg.css' => 'c218ed53',
'core.pkg.js' => '0fabde4f', 'core.pkg.js' => '8581cd02',
'differential.pkg.css' => '113e692c', 'differential.pkg.css' => '113e692c',
'differential.pkg.js' => 'f6d809c0', 'differential.pkg.js' => 'f6d809c0',
'diffusion.pkg.css' => 'a2d17c7d', 'diffusion.pkg.css' => 'a2d17c7d',
@ -352,7 +352,7 @@ return array(
'rsrc/image/texture/table_header_tall.png' => 'd56b434f', 'rsrc/image/texture/table_header_tall.png' => 'd56b434f',
'rsrc/js/application/aphlict/Aphlict.js' => 'e1d4b11a', 'rsrc/js/application/aphlict/Aphlict.js' => 'e1d4b11a',
'rsrc/js/application/aphlict/behavior-aphlict-dropdown.js' => 'caade6f2', 'rsrc/js/application/aphlict/behavior-aphlict-dropdown.js' => 'caade6f2',
'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => '4cc4f460', 'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => '599a8f5f',
'rsrc/js/application/aphlict/behavior-aphlict-status.js' => '5e2634b9', 'rsrc/js/application/aphlict/behavior-aphlict-status.js' => '5e2634b9',
'rsrc/js/application/aphlict/behavior-desktop-notifications-control.js' => '27ca6289', 'rsrc/js/application/aphlict/behavior-desktop-notifications-control.js' => '27ca6289',
'rsrc/js/application/calendar/behavior-day-view.js' => '4b3c4443', 'rsrc/js/application/calendar/behavior-day-view.js' => '4b3c4443',
@ -445,7 +445,7 @@ return array(
'rsrc/js/core/KeyboardShortcut.js' => '1ae869f2', 'rsrc/js/core/KeyboardShortcut.js' => '1ae869f2',
'rsrc/js/core/KeyboardShortcutManager.js' => 'c19dd9b9', 'rsrc/js/core/KeyboardShortcutManager.js' => 'c19dd9b9',
'rsrc/js/core/MultirowRowManager.js' => 'b5d57730', 'rsrc/js/core/MultirowRowManager.js' => 'b5d57730',
'rsrc/js/core/Notification.js' => '008faf9c', 'rsrc/js/core/Notification.js' => '4f774dac',
'rsrc/js/core/Prefab.js' => '77b0ae28', 'rsrc/js/core/Prefab.js' => '77b0ae28',
'rsrc/js/core/ShapedRequest.js' => '7cbe244b', 'rsrc/js/core/ShapedRequest.js' => '7cbe244b',
'rsrc/js/core/TextAreaUtils.js' => '320810c8', 'rsrc/js/core/TextAreaUtils.js' => '320810c8',
@ -566,7 +566,7 @@ return array(
'javelin-aphlict' => 'e1d4b11a', 'javelin-aphlict' => 'e1d4b11a',
'javelin-behavior' => '61cbc29a', 'javelin-behavior' => '61cbc29a',
'javelin-behavior-aphlict-dropdown' => 'caade6f2', 'javelin-behavior-aphlict-dropdown' => 'caade6f2',
'javelin-behavior-aphlict-listen' => '4cc4f460', 'javelin-behavior-aphlict-listen' => '599a8f5f',
'javelin-behavior-aphlict-status' => '5e2634b9', 'javelin-behavior-aphlict-status' => '5e2634b9',
'javelin-behavior-aphront-basic-tokenizer' => 'b3a4b884', 'javelin-behavior-aphront-basic-tokenizer' => 'b3a4b884',
'javelin-behavior-aphront-drag-and-drop-textarea' => '484a6e22', 'javelin-behavior-aphront-drag-and-drop-textarea' => '484a6e22',
@ -772,7 +772,7 @@ return array(
'phabricator-keyboard-shortcut-manager' => 'c19dd9b9', 'phabricator-keyboard-shortcut-manager' => 'c19dd9b9',
'phabricator-main-menu-view' => '1802a242', 'phabricator-main-menu-view' => '1802a242',
'phabricator-nav-view-css' => 'a9e3e6d5', 'phabricator-nav-view-css' => 'a9e3e6d5',
'phabricator-notification' => '008faf9c', 'phabricator-notification' => '4f774dac',
'phabricator-notification-css' => '457861ec', 'phabricator-notification-css' => '457861ec',
'phabricator-notification-menu-css' => '10685bd4', 'phabricator-notification-menu-css' => '10685bd4',
'phabricator-object-selector-css' => '85ee8ce6', 'phabricator-object-selector-css' => '85ee8ce6',
@ -894,13 +894,6 @@ return array(
'javelin-typeahead-preloaded-source', 'javelin-typeahead-preloaded-source',
'javelin-util', 'javelin-util',
), ),
'008faf9c' => array(
'javelin-install',
'javelin-dom',
'javelin-stratcom',
'javelin-util',
'phabricator-notification-css',
),
'013ffff9' => array( '013ffff9' => array(
'javelin-install', 'javelin-install',
'javelin-util', 'javelin-util',
@ -1259,20 +1252,6 @@ return array(
'javelin-uri', 'javelin-uri',
'phabricator-notification', 'phabricator-notification',
), ),
'4cc4f460' => array(
'javelin-behavior',
'javelin-aphlict',
'javelin-stratcom',
'javelin-request',
'javelin-uri',
'javelin-dom',
'javelin-json',
'javelin-router',
'javelin-util',
'javelin-leader',
'javelin-sound',
'phabricator-notification',
),
'4d863052' => array( '4d863052' => array(
'javelin-dom', 'javelin-dom',
'javelin-util', 'javelin-util',
@ -1289,6 +1268,13 @@ return array(
'javelin-stratcom', 'javelin-stratcom',
'javelin-dom', 'javelin-dom',
), ),
'4f774dac' => array(
'javelin-install',
'javelin-dom',
'javelin-stratcom',
'javelin-util',
'phabricator-notification-css',
),
'503e17fd' => array( '503e17fd' => array(
'javelin-install', 'javelin-install',
'javelin-typeahead-source', 'javelin-typeahead-source',
@ -1343,6 +1329,20 @@ return array(
'javelin-uri', 'javelin-uri',
'phabricator-file-upload', 'phabricator-file-upload',
), ),
'599a8f5f' => array(
'javelin-behavior',
'javelin-aphlict',
'javelin-stratcom',
'javelin-request',
'javelin-uri',
'javelin-dom',
'javelin-json',
'javelin-router',
'javelin-util',
'javelin-leader',
'javelin-sound',
'phabricator-notification',
),
'59a7976a' => array( '59a7976a' => array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',

View file

@ -78,7 +78,7 @@ JX.behavior('aphlict-listen', function(config) {
JX.Stratcom.invoke('notification-panel-update', null, {}); JX.Stratcom.invoke('notification-panel-update', null, {});
var response = e.getData(); var response = e.getData();
if (!response.showAnyNotification) { if (!response.showAnyNotification && !response.showDesktopNotification) {
return; return;
} }
@ -86,6 +86,7 @@ JX.behavior('aphlict-listen', function(config) {
new JX.Notification() new JX.Notification()
.setContent(JX.$H(response.content)) .setContent(JX.$H(response.content))
.setKey(response.primaryObjectPHID) .setKey(response.primaryObjectPHID)
.setShowAsWebNotification(response.showAnyNotification)
.setShowAsDesktopNotification(response.showDesktopNotification) .setShowAsDesktopNotification(response.showDesktopNotification)
.setTitle(response.title) .setTitle(response.title)
.setBody(response.body) .setBody(response.body)

View file

@ -27,6 +27,7 @@ JX.install('Notification', {
_hideTimer : null, _hideTimer : null,
_duration : 12000, _duration : 12000,
_asDesktop : false, _asDesktop : false,
_asWeb : true,
_key : null, _key : null,
_title : null, _title : null,
_body : null, _body : null,
@ -88,6 +89,11 @@ JX.install('Notification', {
return this; return this;
}, },
setShowAsWebNotification: function(mode) {
this._asWeb = mode;
return this;
},
setShowAsDesktopNotification : function(mode) { setShowAsDesktopNotification : function(mode) {
this._asDesktop = mode; this._asDesktop = mode;
return this; return this;
@ -242,6 +248,13 @@ JX.install('Notification', {
var notifications = []; var notifications = [];
for (var ii = 0; ii < self._active.length; ii++) { for (var ii = 0; ii < self._active.length; ii++) {
// Don't render this notification if it's not configured to show as
// a web notification.
if (!self._active[ii]._asWeb) {
continue;
}
notifications.push(self._active[ii]._getContainer()); notifications.push(self._active[ii]._getContainer());
if (!(--limit)) { if (!(--limit)) {
break; break;