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

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

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => 'e68cf1fa', 'conpherence.pkg.css' => 'e68cf1fa',
'conpherence.pkg.js' => 'b5b51108', 'conpherence.pkg.js' => 'b5b51108',
'core.pkg.css' => 'e9473020', 'core.pkg.css' => 'e9473020',
'core.pkg.js' => '6c085267', 'core.pkg.js' => '28552e58',
'darkconsole.pkg.js' => '1f9a31bc', 'darkconsole.pkg.js' => '1f9a31bc',
'differential.pkg.css' => '45951e9e', 'differential.pkg.css' => '45951e9e',
'differential.pkg.js' => 'b71b8c5d', 'differential.pkg.js' => 'b71b8c5d',
@ -374,7 +374,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' => 'a14cbdfc', 'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => '4cc4f460',
'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',
@ -467,7 +467,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' => '5c3349b2', 'rsrc/js/core/Notification.js' => '008faf9c',
'rsrc/js/core/Prefab.js' => 'c5af80a2', 'rsrc/js/core/Prefab.js' => 'c5af80a2',
'rsrc/js/core/ShapedRequest.js' => '7cbe244b', 'rsrc/js/core/ShapedRequest.js' => '7cbe244b',
'rsrc/js/core/TextAreaUtils.js' => '320810c8', 'rsrc/js/core/TextAreaUtils.js' => '320810c8',
@ -585,7 +585,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' => 'a14cbdfc', 'javelin-behavior-aphlict-listen' => '4cc4f460',
'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',
@ -789,7 +789,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' => 'faf6a6fc', 'phabricator-nav-view-css' => 'faf6a6fc',
'phabricator-notification' => '5c3349b2', 'phabricator-notification' => '008faf9c',
'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',
@ -904,6 +904,13 @@ return array(
'unhandled-exception-css' => '4c96257a', 'unhandled-exception-css' => '4c96257a',
), ),
'requires' => array( 'requires' => array(
'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',
@ -1236,6 +1243,20 @@ 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',
@ -1326,13 +1347,6 @@ return array(
'javelin-vector', 'javelin-vector',
'javelin-dom', 'javelin-dom',
), ),
'5c3349b2' => array(
'javelin-install',
'javelin-dom',
'javelin-stratcom',
'javelin-util',
'phabricator-notification-css',
),
'5c54cbf3' => array( '5c54cbf3' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -1684,20 +1698,6 @@ return array(
'javelin-util', 'javelin-util',
'phabricator-keyboard-shortcut', 'phabricator-keyboard-shortcut',
), ),
'a14cbdfc' => 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',
),
'a3a63478' => array( 'a3a63478' => array(
'phui-workcard-view-css', 'phui-workcard-view-css',
), ),

View file

@ -153,8 +153,8 @@ final class PhabricatorNotificationBuilder extends Phobject {
foreach ($stories as $story) { foreach ($stories as $story) {
if ($story instanceof PhabricatorApplicationTransactionFeedStory) { if ($story instanceof PhabricatorApplicationTransactionFeedStory) {
$dict[] = array( $dict[] = array(
'desktopReady' => $desktop_ready, 'showAnyNotification' => $web_ready,
'webReady' => $web_ready, 'showDesktopNotification' => $desktop_ready,
'title' => $story->renderText(), 'title' => $story->renderText(),
'body' => $story->renderTextBody(), 'body' => $story->renderTextBody(),
'href' => $story->getURI(), 'href' => $story->getURI(),
@ -162,8 +162,8 @@ final class PhabricatorNotificationBuilder extends Phobject {
); );
} else if ($story instanceof PhabricatorNotificationTestFeedStory) { } else if ($story instanceof PhabricatorNotificationTestFeedStory) {
$dict[] = array( $dict[] = array(
'desktopReady' => $desktop_ready, 'showAnyNotification' => $web_ready,
'webReady' => $web_ready, 'showDesktopNotification' => $desktop_ready,
'title' => pht('Test Notification'), 'title' => pht('Test Notification'),
'body' => $story->renderText(), 'body' => $story->renderText(),
'href' => null, 'href' => null,
@ -171,8 +171,8 @@ final class PhabricatorNotificationBuilder extends Phobject {
); );
} else { } else {
$dict[] = array( $dict[] = array(
'desktopReady' => false, 'showWebNotification' => false,
'webReady' => false, 'showDesktopNotification' => false,
'title' => null, 'title' => null,
'body' => null, 'body' => null,
'href' => null, 'href' => null,

View file

@ -38,15 +38,9 @@ final class PhabricatorNotificationIndividualController
$dict = $builder->buildDict(); $dict = $builder->buildDict();
$data = $dict[0]; $data = $dict[0];
$response = array( $response = $data + array(
'pertinent' => true, 'pertinent' => true,
'primaryObjectPHID' => $story->getPrimaryObjectPHID(), 'primaryObjectPHID' => $story->getPrimaryObjectPHID(),
'desktopReady' => $data['desktopReady'],
'webReady' => $data['webReady'],
'href' => $data['href'],
'icon' => $data['icon'],
'title' => $data['title'],
'body' => $data['body'],
'content' => hsprintf('%s', $content), 'content' => hsprintf('%s', $content),
'uniqueID' => 'story/'.$story->getChronologicalKey(), 'uniqueID' => 'story/'.$story->getChronologicalKey(),
); );

View file

@ -78,12 +78,15 @@ 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) {
return;
}
// Show the notification itself. // Show the notification itself.
new JX.Notification() new JX.Notification()
.setContent(JX.$H(response.content)) .setContent(JX.$H(response.content))
.setDesktopReady(response.desktopReady)
.setWebReady(response.webReady)
.setKey(response.primaryObjectPHID) .setKey(response.primaryObjectPHID)
.setShowAsDesktopNotification(response.showDesktopNotification)
.setTitle(response.title) .setTitle(response.title)
.setBody(response.body) .setBody(response.body)
.setHref(response.href) .setHref(response.href)

View file

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