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

Allow more granularity on real-time notifications

Summary: Fixes T12792. Expands the Notifications to "web, desktop, both, or none" for real-time notifications in settings.

Test Plan: Test with "test notifications" button, and while logged into two accounts with each of the 4 settings.

Reviewers: epriestley

Reviewed By: epriestley

Spies: Korvin

Maniphest Tasks: T12792

Differential Revision: https://secure.phabricator.com/D18457
This commit is contained in:
Chad Little 2017-08-23 14:35:02 -07:00
parent 8c4f5aba33
commit 63bd1784b0
10 changed files with 140 additions and 79 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' => 'fe4effd6', 'core.pkg.css' => 'fe4effd6',
'core.pkg.js' => '5d80e0db', 'core.pkg.js' => '396dee49',
'darkconsole.pkg.js' => '1f9a31bc', 'darkconsole.pkg.js' => '1f9a31bc',
'differential.pkg.css' => '45951e9e', 'differential.pkg.css' => '45951e9e',
'differential.pkg.js' => 'b71b8c5d', 'differential.pkg.js' => 'b71b8c5d',
@ -375,9 +375,9 @@ 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' => '3c547a81', 'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => 'a14cbdfc',
'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' => 'd5a2d665', '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',
'rsrc/js/application/calendar/behavior-event-all-day.js' => 'b41537c9', 'rsrc/js/application/calendar/behavior-event-all-day.js' => 'b41537c9',
'rsrc/js/application/calendar/behavior-month-view.js' => 'fe33e256', 'rsrc/js/application/calendar/behavior-month-view.js' => 'fe33e256',
@ -468,7 +468,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' => 'ccf1cbf8', 'rsrc/js/core/Notification.js' => '5c3349b2',
'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',
@ -587,7 +587,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' => '3c547a81', 'javelin-behavior-aphlict-listen' => 'a14cbdfc',
'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',
@ -612,7 +612,7 @@ return array(
'javelin-behavior-dashboard-query-panel-select' => '453c5375', 'javelin-behavior-dashboard-query-panel-select' => '453c5375',
'javelin-behavior-dashboard-tab-panel' => 'd4eecc63', 'javelin-behavior-dashboard-tab-panel' => 'd4eecc63',
'javelin-behavior-day-view' => '4b3c4443', 'javelin-behavior-day-view' => '4b3c4443',
'javelin-behavior-desktop-notifications-control' => 'd5a2d665', 'javelin-behavior-desktop-notifications-control' => '27ca6289',
'javelin-behavior-detect-timezone' => '4c193c96', 'javelin-behavior-detect-timezone' => '4c193c96',
'javelin-behavior-device' => 'bb1dd507', 'javelin-behavior-device' => 'bb1dd507',
'javelin-behavior-diff-preview-link' => '051c7832', 'javelin-behavior-diff-preview-link' => '051c7832',
@ -791,7 +791,7 @@ return array(
'phabricator-keyboard-shortcut-manager' => 'c19dd9b9', 'phabricator-keyboard-shortcut-manager' => 'c19dd9b9',
'phabricator-main-menu-view' => '16053029', 'phabricator-main-menu-view' => '16053029',
'phabricator-nav-view-css' => 'faf6a6fc', 'phabricator-nav-view-css' => 'faf6a6fc',
'phabricator-notification' => 'ccf1cbf8', 'phabricator-notification' => '5c3349b2',
'phabricator-notification-css' => '3f6c89c9', 'phabricator-notification-css' => '3f6c89c9',
'phabricator-notification-menu-css' => '73fefdfa', 'phabricator-notification-menu-css' => '73fefdfa',
'phabricator-object-selector-css' => '85ee8ce6', 'phabricator-object-selector-css' => '85ee8ce6',
@ -1058,6 +1058,13 @@ return array(
'phabricator-drag-and-drop-file-upload', 'phabricator-drag-and-drop-file-upload',
'javelin-workboard-board', 'javelin-workboard-board',
), ),
'27ca6289' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'javelin-uri',
'phabricator-notification',
),
'2926fff2' => array( '2926fff2' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',
@ -1115,20 +1122,6 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-magical-init', 'javelin-magical-init',
), ),
'3c547a81' => 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',
),
'3cb0b2fc' => array( '3cb0b2fc' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-dom', 'javelin-dom',
@ -1338,6 +1331,13 @@ 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',
@ -1676,6 +1676,20 @@ 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',
),
'a37126bd' => array( 'a37126bd' => array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',
@ -1951,13 +1965,6 @@ return array(
'cae95e89' => array( 'cae95e89' => array(
'syntax-default-css', 'syntax-default-css',
), ),
'ccf1cbf8' => array(
'javelin-install',
'javelin-dom',
'javelin-stratcom',
'javelin-util',
'phabricator-notification-css',
),
'cd2b9b77' => array( 'cd2b9b77' => array(
'phui-oi-list-view-css', 'phui-oi-list-view-css',
), ),
@ -1996,13 +2003,6 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-stratcom', 'javelin-stratcom',
), ),
'd5a2d665' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'javelin-uri',
'phabricator-notification',
),
'd6a7e717' => array( 'd6a7e717' => array(
'multirow-row-manager', 'multirow-row-manager',
'javelin-install', 'javelin-install',

View file

@ -2647,8 +2647,6 @@ phutil_register_library_map(array(
'PhabricatorDebugController' => 'applications/system/controller/PhabricatorDebugController.php', 'PhabricatorDebugController' => 'applications/system/controller/PhabricatorDebugController.php',
'PhabricatorDefaultRequestExceptionHandler' => 'aphront/handler/PhabricatorDefaultRequestExceptionHandler.php', 'PhabricatorDefaultRequestExceptionHandler' => 'aphront/handler/PhabricatorDefaultRequestExceptionHandler.php',
'PhabricatorDefaultSyntaxStyle' => 'infrastructure/syntax/PhabricatorDefaultSyntaxStyle.php', 'PhabricatorDefaultSyntaxStyle' => 'infrastructure/syntax/PhabricatorDefaultSyntaxStyle.php',
'PhabricatorDesktopNotificationsSetting' => 'applications/settings/setting/PhabricatorDesktopNotificationsSetting.php',
'PhabricatorDesktopNotificationsSettingsPanel' => 'applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php',
'PhabricatorDestructibleCodex' => 'applications/system/codex/PhabricatorDestructibleCodex.php', 'PhabricatorDestructibleCodex' => 'applications/system/codex/PhabricatorDestructibleCodex.php',
'PhabricatorDestructibleCodexInterface' => 'applications/system/interface/PhabricatorDestructibleCodexInterface.php', 'PhabricatorDestructibleCodexInterface' => 'applications/system/interface/PhabricatorDestructibleCodexInterface.php',
'PhabricatorDestructibleInterface' => 'applications/system/interface/PhabricatorDestructibleInterface.php', 'PhabricatorDestructibleInterface' => 'applications/system/interface/PhabricatorDestructibleInterface.php',
@ -3214,6 +3212,8 @@ phutil_register_library_map(array(
'PhabricatorNotificationTestFeedStory' => 'applications/notification/feed/PhabricatorNotificationTestFeedStory.php', 'PhabricatorNotificationTestFeedStory' => 'applications/notification/feed/PhabricatorNotificationTestFeedStory.php',
'PhabricatorNotificationUIExample' => 'applications/uiexample/examples/PhabricatorNotificationUIExample.php', 'PhabricatorNotificationUIExample' => 'applications/uiexample/examples/PhabricatorNotificationUIExample.php',
'PhabricatorNotificationsApplication' => 'applications/notification/application/PhabricatorNotificationsApplication.php', 'PhabricatorNotificationsApplication' => 'applications/notification/application/PhabricatorNotificationsApplication.php',
'PhabricatorNotificationsSetting' => 'applications/settings/setting/PhabricatorNotificationsSetting.php',
'PhabricatorNotificationsSettingsPanel' => 'applications/settings/panel/PhabricatorNotificationsSettingsPanel.php',
'PhabricatorNuanceApplication' => 'applications/nuance/application/PhabricatorNuanceApplication.php', 'PhabricatorNuanceApplication' => 'applications/nuance/application/PhabricatorNuanceApplication.php',
'PhabricatorOAuth1AuthProvider' => 'applications/auth/provider/PhabricatorOAuth1AuthProvider.php', 'PhabricatorOAuth1AuthProvider' => 'applications/auth/provider/PhabricatorOAuth1AuthProvider.php',
'PhabricatorOAuth1SecretTemporaryTokenType' => 'applications/auth/provider/PhabricatorOAuth1SecretTemporaryTokenType.php', 'PhabricatorOAuth1SecretTemporaryTokenType' => 'applications/auth/provider/PhabricatorOAuth1SecretTemporaryTokenType.php',
@ -7952,8 +7952,6 @@ phutil_register_library_map(array(
'PhabricatorDebugController' => 'PhabricatorController', 'PhabricatorDebugController' => 'PhabricatorController',
'PhabricatorDefaultRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', 'PhabricatorDefaultRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler',
'PhabricatorDefaultSyntaxStyle' => 'PhabricatorSyntaxStyle', 'PhabricatorDefaultSyntaxStyle' => 'PhabricatorSyntaxStyle',
'PhabricatorDesktopNotificationsSetting' => 'PhabricatorInternalSetting',
'PhabricatorDesktopNotificationsSettingsPanel' => 'PhabricatorSettingsPanel',
'PhabricatorDestructibleCodex' => 'Phobject', 'PhabricatorDestructibleCodex' => 'Phobject',
'PhabricatorDestructionEngine' => 'Phobject', 'PhabricatorDestructionEngine' => 'Phobject',
'PhabricatorDestructionEngineExtension' => 'Phobject', 'PhabricatorDestructionEngineExtension' => 'Phobject',
@ -8577,6 +8575,8 @@ phutil_register_library_map(array(
'PhabricatorNotificationTestFeedStory' => 'PhabricatorFeedStory', 'PhabricatorNotificationTestFeedStory' => 'PhabricatorFeedStory',
'PhabricatorNotificationUIExample' => 'PhabricatorUIExample', 'PhabricatorNotificationUIExample' => 'PhabricatorUIExample',
'PhabricatorNotificationsApplication' => 'PhabricatorApplication', 'PhabricatorNotificationsApplication' => 'PhabricatorApplication',
'PhabricatorNotificationsSetting' => 'PhabricatorInternalSetting',
'PhabricatorNotificationsSettingsPanel' => 'PhabricatorSettingsPanel',
'PhabricatorNuanceApplication' => 'PhabricatorApplication', 'PhabricatorNuanceApplication' => 'PhabricatorApplication',
'PhabricatorOAuth1AuthProvider' => 'PhabricatorOAuthAuthProvider', 'PhabricatorOAuth1AuthProvider' => 'PhabricatorOAuthAuthProvider',
'PhabricatorOAuth1SecretTemporaryTokenType' => 'PhabricatorAuthTemporaryTokenType', 'PhabricatorOAuth1SecretTemporaryTokenType' => 'PhabricatorAuthTemporaryTokenType',

View file

@ -145,13 +145,16 @@ final class PhabricatorNotificationBuilder extends Phobject {
$dict = array(); $dict = array();
$viewer = $this->user; $viewer = $this->user;
$desktop_key = PhabricatorDesktopNotificationsSetting::SETTINGKEY; $key = PhabricatorNotificationsSetting::SETTINGKEY;
$desktop_enabled = $viewer->getUserSetting($desktop_key); $setting = $viewer->getUserSetting($key);
$desktop_ready = PhabricatorNotificationsSetting::desktopReady($setting);
$web_ready = PhabricatorNotificationsSetting::webReady($setting);
foreach ($stories as $story) { foreach ($stories as $story) {
if ($story instanceof PhabricatorApplicationTransactionFeedStory) { if ($story instanceof PhabricatorApplicationTransactionFeedStory) {
$dict[] = array( $dict[] = array(
'desktopReady' => $desktop_enabled, 'desktopReady' => $desktop_ready,
'webReady' => $web_ready,
'title' => $story->renderText(), 'title' => $story->renderText(),
'body' => $story->renderTextBody(), 'body' => $story->renderTextBody(),
'href' => $story->getURI(), 'href' => $story->getURI(),
@ -159,7 +162,8 @@ final class PhabricatorNotificationBuilder extends Phobject {
); );
} else if ($story instanceof PhabricatorNotificationTestFeedStory) { } else if ($story instanceof PhabricatorNotificationTestFeedStory) {
$dict[] = array( $dict[] = array(
'desktopReady' => $desktop_enabled, 'desktopReady' => $desktop_ready,
'webReady' => $web_ready,
'title' => pht('Test Notification'), 'title' => pht('Test Notification'),
'body' => $story->renderText(), 'body' => $story->renderText(),
'href' => null, 'href' => null,
@ -168,6 +172,7 @@ final class PhabricatorNotificationBuilder extends Phobject {
} else { } else {
$dict[] = array( $dict[] = array(
'desktopReady' => false, 'desktopReady' => false,
'webReady' => false,
'title' => null, 'title' => null,
'body' => null, 'body' => null,
'href' => null, 'href' => null,

View file

@ -42,6 +42,7 @@ final class PhabricatorNotificationIndividualController
'pertinent' => true, 'pertinent' => true,
'primaryObjectPHID' => $story->getPrimaryObjectPHID(), 'primaryObjectPHID' => $story->getPrimaryObjectPHID(),
'desktopReady' => $data['desktopReady'], 'desktopReady' => $data['desktopReady'],
'webReady' => $data['webReady'],
'href' => $data['href'], 'href' => $data['href'],
'icon' => $data['icon'], 'icon' => $data['icon'],
'title' => $data['title'], 'title' => $data['title'],

View file

@ -1,6 +1,6 @@
<?php <?php
final class PhabricatorDesktopNotificationsSettingsPanel final class PhabricatorNotificationsSettingsPanel
extends PhabricatorSettingsPanel { extends PhabricatorSettingsPanel {
public function isEnabled() { public function isEnabled() {
@ -14,11 +14,11 @@ final class PhabricatorDesktopNotificationsSettingsPanel
} }
public function getPanelKey() { public function getPanelKey() {
return 'desktopnotifications'; return 'notifications';
} }
public function getPanelName() { public function getPanelName() {
return pht('Desktop Notifications'); return pht('Notifications');
} }
public function getPanelGroupKey() { public function getPanelGroupKey() {
@ -29,7 +29,7 @@ final class PhabricatorDesktopNotificationsSettingsPanel
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$preferences = $this->getPreferences(); $preferences = $this->getPreferences();
$notifications_key = PhabricatorDesktopNotificationsSetting::SETTINGKEY; $notifications_key = PhabricatorNotificationsSetting::SETTINGKEY;
$notifications_value = $preferences->getSettingValue($notifications_key); $notifications_value = $preferences->getSettingValue($notifications_key);
if ($request->isFormPost()) { if ($request->isFormPost()) {
@ -43,7 +43,7 @@ final class PhabricatorDesktopNotificationsSettingsPanel
->setURI($this->getPanelURI('?saved=true')); ->setURI($this->getPanelURI('?saved=true'));
} }
$title = pht('Desktop Notifications'); $title = pht('Notifications');
$control_id = celerity_generate_unique_node_id(); $control_id = celerity_generate_unique_node_id();
$status_id = celerity_generate_unique_node_id(); $status_id = celerity_generate_unique_node_id();
$browser_status_id = celerity_generate_unique_node_id(); $browser_status_id = celerity_generate_unique_node_id();
@ -97,19 +97,31 @@ final class PhabricatorDesktopNotificationsSettingsPanel
'id' => $message_id, 'id' => $message_id,
)); ));
$saved_box = null;
if ($request->getBool('saved')) {
$saved_box = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->appendChild(pht('Changes saved.'));
}
$status_box = id(new PHUIInfoView()) $status_box = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE) ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->setID($status_id) ->setID($status_id)
->setIsHidden(true) ->setIsHidden(true)
->appendChild($message_container); ->appendChild($message_container);
$status_box = id(new PHUIBoxView())
->addClass('mll mlr')
->appendChild($status_box);
$control_config = array( $control_config = array(
'controlID' => $control_id, 'controlID' => $control_id,
'statusID' => $status_id, 'statusID' => $status_id,
'messageID' => $message_id, 'messageID' => $message_id,
'browserStatusID' => $browser_status_id, 'browserStatusID' => $browser_status_id,
'defaultMode' => 0, 'defaultMode' => 0,
'desktopMode' => 1, 'desktop' => 1,
'desktopOnly' => 2,
'cancelAsk' => $cancel_ask, 'cancelAsk' => $cancel_ask,
'grantedAsk' => $accept_ask, 'grantedAsk' => $accept_ask,
'deniedAsk' => $reject_ask, 'deniedAsk' => $reject_ask,
@ -127,16 +139,12 @@ final class PhabricatorDesktopNotificationsSettingsPanel
->setControlID($control_id) ->setControlID($control_id)
->setName($notifications_key) ->setName($notifications_key)
->setValue($notifications_value) ->setValue($notifications_value)
->setOptions( ->setOptions(PhabricatorNotificationsSetting::getOptionsMap())
array(
1 => pht('Send Desktop Notifications Too'),
0 => pht('Send Application Notifications Only'),
))
->setCaption( ->setCaption(
pht( pht(
'Should Phabricator send desktop notifications? These are sent '. 'Phabricator can send real-time notifications to your web browser '.
'in addition to the notifications within the Phabricator '. 'or to your desktop. Select where you\'d want to receive these '.
'application.')) 'real-time updates.'))
->initBehavior( ->initBehavior(
'desktop-notifications-control', 'desktop-notifications-control',
$control_config)) $control_config))
@ -154,12 +162,14 @@ final class PhabricatorDesktopNotificationsSettingsPanel
$form_box = id(new PHUIObjectBoxView()) $form_box = id(new PHUIObjectBoxView())
->setHeader( ->setHeader(
id(new PHUIHeaderView()) id(new PHUIHeaderView())
->setHeader(pht('Desktop Notifications')) ->setHeader(pht('Notifications'))
->addActionLink($test_button)) ->addActionLink($test_button))
->setForm($form)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setInfoView($status_box) ->appendChild(array(
->setFormSaved($request->getBool('saved')); $saved_box,
$status_box,
$form,
));
$browser_status_box = id(new PHUIInfoView()) $browser_status_box = id(new PHUIInfoView())
->setID($browser_status_id) ->setID($browser_status_id)

View file

@ -1,12 +0,0 @@
<?php
final class PhabricatorDesktopNotificationsSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'desktop-notifications';
public function getSettingName() {
return pht('Desktop Notifications');
}
}

View file

@ -0,0 +1,44 @@
<?php
final class PhabricatorNotificationsSetting
extends PhabricatorInternalSetting {
const SETTINGKEY = 'desktop-notifications';
const WEB_ONLY = 0;
const WEB_AND_DESKTOP = 1;
const DESKTOP_ONLY = 2;
const NONE = 3;
public function getSettingName() {
return pht('Notifications');
}
public static function getOptionsMap() {
return array(
self::WEB_ONLY => pht('Web Only'),
self::WEB_AND_DESKTOP => pht('Web and Desktop'),
self::DESKTOP_ONLY => pht('Desktop Only'),
self::NONE => pht('No Notifications'),
);
}
public static function desktopReady($option) {
switch ($option) {
case self::WEB_AND_DESKTOP:
case self::DESKTOP_ONLY:
return true;
}
return false;
}
public static function webReady($option) {
switch ($option) {
case self::WEB_AND_DESKTOP:
case self::WEB_ONLY:
return true;
}
return false;
}
}

View file

@ -82,6 +82,7 @@ JX.behavior('aphlict-listen', function(config) {
new JX.Notification() new JX.Notification()
.setContent(JX.$H(response.content)) .setContent(JX.$H(response.content))
.setDesktopReady(response.desktopReady) .setDesktopReady(response.desktopReady)
.setWebReady(response.webReady)
.setKey(response.primaryObjectPHID) .setKey(response.primaryObjectPHID)
.setTitle(response.title) .setTitle(response.title)
.setBody(response.body) .setBody(response.body)

View file

@ -84,12 +84,12 @@ JX.behavior('desktop-notifications-control', function(config, statics) {
return; return;
} }
var value = e.getTarget().value; var value = e.getTarget().value;
if (value == config.desktopMode) { if ((value == config.desktop) || (value == config.desktopOnly)) {
window.Notification.requestPermission( window.Notification.requestPermission(
function (permission) { function (permission) {
updateFormStatus(permission); updateFormStatus(permission);
updateBrowserStatus(permission); updateBrowserStatus(permission);
}); });
} else { } else {
var statusEl = JX.$(config.statusID); var statusEl = JX.$(config.statusID);
JX.DOM.hide(statusEl); JX.DOM.hide(statusEl);

View file

@ -27,6 +27,7 @@ JX.install('Notification', {
_hideTimer : null, _hideTimer : null,
_duration : 12000, _duration : 12000,
_desktopReady : false, _desktopReady : false,
_webReady : false,
_key : null, _key : null,
_title : null, _title : null,
_body : null, _body : null,
@ -35,6 +36,12 @@ 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;
@ -92,6 +99,11 @@ JX.install('Notification', {
return this; return this;
}, },
setWebReady : function(ready) {
this._webReady = ready;
return this;
},
setTitle : function(title) { setTitle : function(title) {
this._title = title; this._title = title;
return this; return this;