mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +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:
parent
8cd0997965
commit
7a4ca85d67
3 changed files with 56 additions and 32 deletions
|
@ -779,16 +779,17 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'javelin-behavior-aphlict-listen' =>
|
||||
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',
|
||||
'requires' =>
|
||||
array(
|
||||
0 => 'javelin-behavior',
|
||||
1 => 'javelin-aphlict',
|
||||
2 => 'javelin-util',
|
||||
3 => 'javelin-stratcom',
|
||||
4 => 'javelin-behavior-aphlict-dropdown',
|
||||
5 => 'phabricator-notification',
|
||||
2 => 'javelin-stratcom',
|
||||
3 => 'javelin-request',
|
||||
4 => 'javelin-uri',
|
||||
5 => 'javelin-dom',
|
||||
6 => 'phabricator-notification',
|
||||
),
|
||||
'disk' => '/rsrc/js/application/aphlict/behavior-aphlict-listen.js',
|
||||
),
|
||||
|
|
|
@ -404,12 +404,11 @@ final class PhabricatorStandardPageView extends AphrontPageView {
|
|||
'id' => $aphlict_object_id,
|
||||
'server' => $client_uri->getDomain(),
|
||||
'port' => $client_uri->getPort(),
|
||||
'pageObjects' => $this->pageObjects,
|
||||
'pageObjects' => array_fill_keys($this->pageObjects, true),
|
||||
));
|
||||
|
||||
Javelin::initBehavior('aphlict-dropdown', array());
|
||||
|
||||
|
||||
$notification_count = id(new PhabricatorFeedStoryNotification())
|
||||
->countUnread($user);
|
||||
|
||||
|
|
|
@ -2,42 +2,66 @@
|
|||
* @provides javelin-behavior-aphlict-listen
|
||||
* @requires javelin-behavior
|
||||
* javelin-aphlict
|
||||
* javelin-util
|
||||
* javelin-stratcom
|
||||
* javelin-behavior-aphlict-dropdown
|
||||
* javelin-request
|
||||
* javelin-uri
|
||||
* javelin-dom
|
||||
* phabricator-notification
|
||||
*/
|
||||
|
||||
JX.behavior('aphlict-listen', function(config) {
|
||||
|
||||
var showing_reload = false;
|
||||
|
||||
function onready() {
|
||||
|
||||
var client = new JX.Aphlict(config.id, config.server, config.port)
|
||||
.setHandler(function(type, message) {
|
||||
if (message) {
|
||||
if (type == 'receive') {
|
||||
var request = new JX.Request('/notification/individual/',
|
||||
function(response) {
|
||||
if (response.pertinent) {
|
||||
if (config.pageObjects.indexOf(response.primaryObjectPHID)
|
||||
> -1) {
|
||||
var notification = new JX.Notification()
|
||||
.setContent('Page updated. Please refresh.')
|
||||
.setDuration(0) // never timeout
|
||||
.show();
|
||||
}
|
||||
|
||||
JX.Stratcom.invoke('notification-panel-update', null, {});
|
||||
}
|
||||
});
|
||||
request.addData({ "key": message.key });
|
||||
request.send();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setHandler(onaphlictmessage)
|
||||
.start();
|
||||
}
|
||||
|
||||
|
||||
// Respond to a notification from the Aphlict notification server. We send
|
||||
// a request to Phabricator to get notification details.
|
||||
function onaphlictmessage(type, message) {
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
|
||||
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, {});
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Wait for the element to load, and don't do anything if it never loads.
|
||||
// If we just go crazy and start making calls to it before it loads, its
|
||||
// interfaces won't be registered yet.
|
||||
|
|
Loading…
Reference in a new issue