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

Show only one "reload" popup, use 'alert' style, click to reload

Summary: Use the features from D2758.

Test Plan: Updated T1 with two browser windows pointing at it, verified reload appeared, only one reload, and it appeared with 'alert' style.

Reviewers: jungejason, vrana

Reviewed By: jungejason

CC: aran

Maniphest Tasks: T944

Differential Revision: https://secure.phabricator.com/D2781
This commit is contained in:
epriestley 2012-06-18 14:07:45 -07:00
parent 8cd0997965
commit 7a4ca85d67
3 changed files with 56 additions and 32 deletions

View file

@ -779,16 +779,17 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-aphlict-listen' => 'javelin-behavior-aphlict-listen' =>
array( array(
'uri' => '/res/4b1dc678/rsrc/js/application/aphlict/behavior-aphlict-listen.js', 'uri' => '/res/204f141a/rsrc/js/application/aphlict/behavior-aphlict-listen.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
1 => 'javelin-aphlict', 1 => 'javelin-aphlict',
2 => 'javelin-util', 2 => 'javelin-stratcom',
3 => 'javelin-stratcom', 3 => 'javelin-request',
4 => 'javelin-behavior-aphlict-dropdown', 4 => 'javelin-uri',
5 => 'phabricator-notification', 5 => 'javelin-dom',
6 => 'phabricator-notification',
), ),
'disk' => '/rsrc/js/application/aphlict/behavior-aphlict-listen.js', 'disk' => '/rsrc/js/application/aphlict/behavior-aphlict-listen.js',
), ),

View file

@ -404,12 +404,11 @@ final class PhabricatorStandardPageView extends AphrontPageView {
'id' => $aphlict_object_id, 'id' => $aphlict_object_id,
'server' => $client_uri->getDomain(), 'server' => $client_uri->getDomain(),
'port' => $client_uri->getPort(), 'port' => $client_uri->getPort(),
'pageObjects' => $this->pageObjects, 'pageObjects' => array_fill_keys($this->pageObjects, true),
)); ));
Javelin::initBehavior('aphlict-dropdown', array()); Javelin::initBehavior('aphlict-dropdown', array());
$notification_count = id(new PhabricatorFeedStoryNotification()) $notification_count = id(new PhabricatorFeedStoryNotification())
->countUnread($user); ->countUnread($user);

View file

@ -2,39 +2,63 @@
* @provides javelin-behavior-aphlict-listen * @provides javelin-behavior-aphlict-listen
* @requires javelin-behavior * @requires javelin-behavior
* javelin-aphlict * javelin-aphlict
* javelin-util
* javelin-stratcom * javelin-stratcom
* javelin-behavior-aphlict-dropdown * javelin-request
* javelin-uri
* javelin-dom
* phabricator-notification * phabricator-notification
*/ */
JX.behavior('aphlict-listen', function(config) { JX.behavior('aphlict-listen', function(config) {
function onready() {
var showing_reload = false;
function onready() {
var client = new JX.Aphlict(config.id, config.server, config.port) var client = new JX.Aphlict(config.id, config.server, config.port)
.setHandler(function(type, message) { .setHandler(onaphlictmessage)
if (message) { .start();
if (type == 'receive') { }
var request = new JX.Request('/notification/individual/',
function(response) {
if (response.pertinent) { // Respond to a notification from the Aphlict notification server. We send
if (config.pageObjects.indexOf(response.primaryObjectPHID) // a request to Phabricator to get notification details.
> -1) { function onaphlictmessage(type, message) {
var notification = new JX.Notification() if (!message) {
.setContent('Page updated. Please refresh.') return;
.setDuration(0) // never timeout }
.show();
if (type != 'receive') {
return;
}
var request = new JX.Request('/notification/individual/', onnotification)
.addData({key: message.key})
.send();
}
// Respond to a response from Phabricator about a specific notification.
function onnotification(response) {
if (!response.pertinent) {
return;
} }
JX.Stratcom.invoke('notification-panel-update', null, {}); JX.Stratcom.invoke('notification-panel-update', null, {});
// If the notification affected an object on this page, show a
// permanent reload notification if we aren't already.
if ((response.primaryObjectPHID in config.pageObjects) &&
!showing_reload) {
var reload = new JX.Notification()
.setContent('Page updated, click to reload.')
.setClassName('jx-notification-alert')
.setDuration(0);
reload.listen('activate', function(e) { JX.$U().go(); })
reload.show();
showing_reload = true;
} }
});
request.addData({ "key": message.key });
request.send();
}
}
})
.start();
} }