mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-18 02:31:10 +01:00
Multiplex AJAX calls
Summary: Fixes T5344. Essentially, we only make the AJAX request to `/notification/individual/` if we are the leader tab (i.e. only one tab will make this request). Once a response has been received from the server (containing the contents of the notification), we broadcast the message contents back to all other tabs for rendering. Test Plan: Opened two tabs on `/notification/status/` and clicked "Send Test Notification". **Before** ```lang=bash, name=tail -f /var/log/phabricator-access.log | grep /notification/individual/ [Tue, 13 Jan 2015 20:10:37 +1100] 17033 phabricator 10.0.0.1 josh PhabricatorNotificationIndividualController - /notification/individual/-200 236036 [Tue, 13 Jan 2015 20:10:37 +1100] 17657 phabricator 10.0.0.1 josh PhabricatorNotificationIndividualController - /notification/individual/-200 24130 ``` **After** ```lang=bash, name=tail -f /var/log/phabricator-access.log | grep /notification/individual/ [Tue, 13 Jan 2015 20:11:15 +1100] 17657 phabricator 10.0.0.1 josh PhabricatorNotificationIndividualController - /notification/individual/-200 180217 ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T5344 Differential Revision: https://secure.phabricator.com/D11360
This commit is contained in:
parent
62dfcd1e55
commit
4135752490
4 changed files with 69 additions and 49 deletions
|
@ -8,7 +8,7 @@
|
|||
return array(
|
||||
'names' => array(
|
||||
'core.pkg.css' => '8d1c0f87',
|
||||
'core.pkg.js' => 'b6a9c22a',
|
||||
'core.pkg.js' => '7923c2e6',
|
||||
'darkconsole.pkg.js' => '8ab24e01',
|
||||
'differential.pkg.css' => '8af45893',
|
||||
'differential.pkg.js' => 'dad3622f',
|
||||
|
@ -342,14 +342,14 @@ return array(
|
|||
'rsrc/image/texture/table_header.png' => '5c433037',
|
||||
'rsrc/image/texture/table_header_hover.png' => '038ec3b9',
|
||||
'rsrc/image/texture/table_header_tall.png' => 'd56b434f',
|
||||
'rsrc/js/application/aphlict/Aphlict.js' => 'b300dac3',
|
||||
'rsrc/js/application/aphlict/Aphlict.js' => '2be71d56',
|
||||
'rsrc/js/application/aphlict/behavior-aphlict-dropdown.js' => '335470d7',
|
||||
'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => '62998733',
|
||||
'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => '851f167c',
|
||||
'rsrc/js/application/aphlict/behavior-aphlict-status.js' => 'ea681761',
|
||||
'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18',
|
||||
'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de',
|
||||
'rsrc/js/application/conpherence/behavior-menu.js' => 'f0a41b9f',
|
||||
'rsrc/js/application/conpherence/behavior-pontificate.js' => 'e23dfe0f',
|
||||
'rsrc/js/application/conpherence/behavior-pontificate.js' => '2f6efe18',
|
||||
'rsrc/js/application/conpherence/behavior-widget-pane.js' => '40b1ff90',
|
||||
'rsrc/js/application/countdown/timer.js' => 'e4cc26b3',
|
||||
'rsrc/js/application/dashboard/behavior-dashboard-async-panel.js' => '469c0d9e',
|
||||
|
@ -535,10 +535,10 @@ return array(
|
|||
'herald-rule-editor' => '335fd41f',
|
||||
'herald-test-css' => '778b008e',
|
||||
'inline-comment-summary-css' => '8cfd34e8',
|
||||
'javelin-aphlict' => 'b300dac3',
|
||||
'javelin-aphlict' => '2be71d56',
|
||||
'javelin-behavior' => '61cbc29a',
|
||||
'javelin-behavior-aphlict-dropdown' => '335470d7',
|
||||
'javelin-behavior-aphlict-listen' => '62998733',
|
||||
'javelin-behavior-aphlict-listen' => '851f167c',
|
||||
'javelin-behavior-aphlict-status' => 'ea681761',
|
||||
'javelin-behavior-aphront-basic-tokenizer' => 'b3a4b884',
|
||||
'javelin-behavior-aphront-crop' => 'fa0f4fc2',
|
||||
|
@ -552,7 +552,7 @@ return array(
|
|||
'javelin-behavior-choose-control' => '6153c708',
|
||||
'javelin-behavior-config-reorder-fields' => '14a827de',
|
||||
'javelin-behavior-conpherence-menu' => 'f0a41b9f',
|
||||
'javelin-behavior-conpherence-pontificate' => 'e23dfe0f',
|
||||
'javelin-behavior-conpherence-pontificate' => '2f6efe18',
|
||||
'javelin-behavior-conpherence-widget-pane' => '40b1ff90',
|
||||
'javelin-behavior-countdown-timer' => 'e4cc26b3',
|
||||
'javelin-behavior-dark-console' => '08883e8b',
|
||||
|
@ -975,6 +975,13 @@ return array(
|
|||
'javelin-install',
|
||||
'javelin-util',
|
||||
),
|
||||
'2be71d56' => array(
|
||||
'javelin-install',
|
||||
'javelin-util',
|
||||
'javelin-websocket',
|
||||
'javelin-leader',
|
||||
'javelin-json',
|
||||
),
|
||||
'2bfa2836' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
|
@ -986,6 +993,13 @@ return array(
|
|||
'javelin-stratcom',
|
||||
'phabricator-keyboard-shortcut',
|
||||
),
|
||||
'2f6efe18' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
'javelin-util',
|
||||
'javelin-workflow',
|
||||
'javelin-stratcom',
|
||||
),
|
||||
'316b8fa1' => array(
|
||||
'javelin-install',
|
||||
'javelin-typeahead-source',
|
||||
|
@ -1212,18 +1226,6 @@ return array(
|
|||
'javelin-magical-init',
|
||||
'javelin-util',
|
||||
),
|
||||
62998733 => array(
|
||||
'javelin-behavior',
|
||||
'javelin-aphlict',
|
||||
'javelin-stratcom',
|
||||
'javelin-request',
|
||||
'javelin-uri',
|
||||
'javelin-dom',
|
||||
'javelin-json',
|
||||
'javelin-router',
|
||||
'javelin-util',
|
||||
'phabricator-notification',
|
||||
),
|
||||
'6453c869' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
|
@ -1381,6 +1383,19 @@ return array(
|
|||
'javelin-workflow',
|
||||
'phabricator-draggable-list',
|
||||
),
|
||||
'851f167c' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-aphlict',
|
||||
'javelin-stratcom',
|
||||
'javelin-request',
|
||||
'javelin-uri',
|
||||
'javelin-dom',
|
||||
'javelin-json',
|
||||
'javelin-router',
|
||||
'javelin-util',
|
||||
'javelin-leader',
|
||||
'phabricator-notification',
|
||||
),
|
||||
'85ea0626' => array(
|
||||
'javelin-install',
|
||||
),
|
||||
|
@ -1581,13 +1596,6 @@ return array(
|
|||
'javelin-dom',
|
||||
'phortune-credit-card-form',
|
||||
),
|
||||
'b300dac3' => array(
|
||||
'javelin-install',
|
||||
'javelin-util',
|
||||
'javelin-websocket',
|
||||
'javelin-leader',
|
||||
'javelin-json',
|
||||
),
|
||||
'b3a4b884' => array(
|
||||
'javelin-behavior',
|
||||
'phabricator-prefab',
|
||||
|
@ -1777,13 +1785,6 @@ return array(
|
|||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
),
|
||||
'e23dfe0f' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
'javelin-util',
|
||||
'javelin-workflow',
|
||||
'javelin-stratcom',
|
||||
),
|
||||
'e32d14ab' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
|
|
|
@ -116,9 +116,9 @@ JX.install('Aphlict', {
|
|||
}
|
||||
break;
|
||||
|
||||
case 'aphlict.server':
|
||||
default:
|
||||
var handler = this.getHandler();
|
||||
handler && handler(message.data);
|
||||
handler && handler(message);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -9,38 +9,49 @@
|
|||
* javelin-json
|
||||
* javelin-router
|
||||
* javelin-util
|
||||
* javelin-leader
|
||||
* phabricator-notification
|
||||
*/
|
||||
|
||||
JX.behavior('aphlict-listen', function(config) {
|
||||
var showing_reload = false;
|
||||
|
||||
JX.Stratcom.listen('aphlict-receive-message', null, function(e) {
|
||||
JX.Stratcom.listen('aphlict-server-message', null, function(e) {
|
||||
var message = e.getData();
|
||||
|
||||
if (message.type != 'notification') {
|
||||
return;
|
||||
}
|
||||
|
||||
var request = new JX.Request(
|
||||
'/notification/individual/',
|
||||
onNotification);
|
||||
JX.Leader.callIfLeader(function() {
|
||||
var request = new JX.Request(
|
||||
'/notification/individual/',
|
||||
onNotification);
|
||||
|
||||
var routable = request
|
||||
.addData({key: message.key})
|
||||
.getRoutable();
|
||||
var routable = request
|
||||
.addData({key: message.key})
|
||||
.getRoutable();
|
||||
|
||||
routable
|
||||
.setType('notification')
|
||||
.setPriority(250);
|
||||
routable
|
||||
.setType('notification')
|
||||
.setPriority(250);
|
||||
|
||||
JX.Router.getInstance().queue(routable);
|
||||
JX.Router.getInstance().queue(routable);
|
||||
});
|
||||
});
|
||||
|
||||
// Respond to a notification from the Aphlict notification server. We send
|
||||
// a request to Phabricator to get notification details.
|
||||
function onAphlictMessage(message) {
|
||||
JX.Stratcom.invoke('aphlict-receive-message', null, message);
|
||||
switch (message.type) {
|
||||
case 'aphlict.server':
|
||||
JX.Stratcom.invoke('aphlict-server-message', null, message.data);
|
||||
break;
|
||||
|
||||
case 'notification.individual':
|
||||
JX.Stratcom.invoke('aphlict-notification-message', null, message.data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Respond to a response from Phabricator about a specific notification.
|
||||
|
@ -49,7 +60,15 @@ JX.behavior('aphlict-listen', function(config) {
|
|||
return;
|
||||
}
|
||||
|
||||
JX.Leader.broadcast(null, {
|
||||
type: 'notification.individual',
|
||||
data: response
|
||||
});
|
||||
}
|
||||
|
||||
JX.Stratcom.listen('aphlict-notification-message', null, function(e) {
|
||||
JX.Stratcom.invoke('notification-panel-update', null, {});
|
||||
var response = e.getData();
|
||||
|
||||
// Show the notification itself.
|
||||
new JX.Notification()
|
||||
|
@ -68,7 +87,7 @@ JX.behavior('aphlict-listen', function(config) {
|
|||
|
||||
showing_reload = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var client = new JX.Aphlict(
|
||||
config.websocketURI,
|
||||
|
|
|
@ -33,7 +33,7 @@ JX.behavior('conpherence-pontificate', function() {
|
|||
infonode.value = id;
|
||||
}
|
||||
|
||||
JX.Stratcom.listen('aphlict-receive-message', null, function(e) {
|
||||
JX.Stratcom.listen('aphlict-server-message', null, function(e) {
|
||||
var message = e.getData();
|
||||
|
||||
if (message.type != 'message') {
|
||||
|
|
Loading…
Reference in a new issue