mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 10:12:41 +01:00
Fix several duplication/replay behaviors in Aphlict
Summary: Ref T12566. Ref T12563. This fixes three bugs with Aphlict replay stuff: First, Conphernece would try to repaint the UI even if no thread was open. Only repaint when a thread is open. Second, although we deduplicate JX.Leader messages, we didn't deduplicate actual notification messages. If you browsed the leader window, then it re-elected itelf as a leader and replayed history, it could rebroadcast notifications and other windows could show doubles. Deduplicate notifications to prevent this. Third, we always replayed the last 60 seconds of history. When you browsed the leader window, whichever window became the new leader (possibly the one you just browsed) could replay messages from before it had opened, leading to duplicate messages. Particularly, after receiving a message and then browsing you could see that message again. Instead, only replay history as far back as when the window first opened. Test Plan: - Clicked "Repaint" with a thread open, saw a repaint. Clicked "Repaint" with Conpherence open but no thread, no repaint and no 404 request to `/update/null/`. - In browser A, opened three windows. In browser B, sent a notification. In browser A, browsed the leader window away twice in a row. Observed that the window which never became a leader doesn't duplicate notifications. - In browser A, opened three windows. In browser B, sent a notification. In browser A, browsed the leader window away over and over again. Observed that replay requests issued with appropriate history windows. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12566, T12563 Differential Revision: https://secure.phabricator.com/D17722
This commit is contained in:
parent
5d55804e3f
commit
ab2aa74d6e
5 changed files with 67 additions and 44 deletions
|
@ -10,7 +10,7 @@ return array(
|
||||||
'conpherence.pkg.css' => 'a34d59bd',
|
'conpherence.pkg.css' => 'a34d59bd',
|
||||||
'conpherence.pkg.js' => '5f86c17d',
|
'conpherence.pkg.js' => '5f86c17d',
|
||||||
'core.pkg.css' => '959330a2',
|
'core.pkg.css' => '959330a2',
|
||||||
'core.pkg.js' => '5363ae35',
|
'core.pkg.js' => '47a69358',
|
||||||
'darkconsole.pkg.js' => '1f9a31bc',
|
'darkconsole.pkg.js' => '1f9a31bc',
|
||||||
'differential.pkg.css' => '90b30783',
|
'differential.pkg.css' => '90b30783',
|
||||||
'differential.pkg.js' => 'ddfeb49b',
|
'differential.pkg.js' => 'ddfeb49b',
|
||||||
|
@ -362,16 +362,16 @@ return array(
|
||||||
'rsrc/image/texture/table_header.png' => '5c433037',
|
'rsrc/image/texture/table_header.png' => '5c433037',
|
||||||
'rsrc/image/texture/table_header_hover.png' => '038ec3b9',
|
'rsrc/image/texture/table_header_hover.png' => '038ec3b9',
|
||||||
'rsrc/image/texture/table_header_tall.png' => 'd56b434f',
|
'rsrc/image/texture/table_header_tall.png' => 'd56b434f',
|
||||||
'rsrc/js/application/aphlict/Aphlict.js' => '674e335f',
|
'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' => '06e7f30e',
|
'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => '3c547a81',
|
||||||
'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' => 'd5a2d665',
|
||||||
'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',
|
||||||
'rsrc/js/application/config/behavior-reorder-fields.js' => 'b6993408',
|
'rsrc/js/application/config/behavior-reorder-fields.js' => 'b6993408',
|
||||||
'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => '311eae46',
|
'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => '4d863052',
|
||||||
'rsrc/js/application/conpherence/behavior-conpherence-search.js' => '9bbf3762',
|
'rsrc/js/application/conpherence/behavior-conpherence-search.js' => '9bbf3762',
|
||||||
'rsrc/js/application/conpherence/behavior-durable-column.js' => 'aa3bd034',
|
'rsrc/js/application/conpherence/behavior-durable-column.js' => 'aa3bd034',
|
||||||
'rsrc/js/application/conpherence/behavior-menu.js' => '80dda04a',
|
'rsrc/js/application/conpherence/behavior-menu.js' => '80dda04a',
|
||||||
|
@ -561,7 +561,7 @@ return array(
|
||||||
'conpherence-message-pane-css' => '14199428',
|
'conpherence-message-pane-css' => '14199428',
|
||||||
'conpherence-notification-css' => 'cef0a3fc',
|
'conpherence-notification-css' => 'cef0a3fc',
|
||||||
'conpherence-participant-pane-css' => '26a3ce56',
|
'conpherence-participant-pane-css' => '26a3ce56',
|
||||||
'conpherence-thread-manager' => '311eae46',
|
'conpherence-thread-manager' => '4d863052',
|
||||||
'conpherence-transaction-css' => '85129c68',
|
'conpherence-transaction-css' => '85129c68',
|
||||||
'd3' => 'a11a5ff2',
|
'd3' => 'a11a5ff2',
|
||||||
'differential-changeset-view-css' => '41af6d25',
|
'differential-changeset-view-css' => '41af6d25',
|
||||||
|
@ -584,10 +584,10 @@ return array(
|
||||||
'herald-rule-editor' => 'd6a7e717',
|
'herald-rule-editor' => 'd6a7e717',
|
||||||
'herald-test-css' => 'a52e323e',
|
'herald-test-css' => 'a52e323e',
|
||||||
'inline-comment-summary-css' => '51efda3a',
|
'inline-comment-summary-css' => '51efda3a',
|
||||||
'javelin-aphlict' => '674e335f',
|
'javelin-aphlict' => 'e1d4b11a',
|
||||||
'javelin-behavior' => '61cbc29a',
|
'javelin-behavior' => '61cbc29a',
|
||||||
'javelin-behavior-aphlict-dropdown' => 'caade6f2',
|
'javelin-behavior-aphlict-dropdown' => 'caade6f2',
|
||||||
'javelin-behavior-aphlict-listen' => '06e7f30e',
|
'javelin-behavior-aphlict-listen' => '3c547a81',
|
||||||
'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',
|
||||||
|
@ -948,20 +948,6 @@ return array(
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
'javelin-workflow',
|
'javelin-workflow',
|
||||||
),
|
),
|
||||||
'06e7f30e' => 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',
|
|
||||||
),
|
|
||||||
'0825c27a' => array(
|
'0825c27a' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
|
@ -1133,17 +1119,6 @@ return array(
|
||||||
'2ee659ce' => array(
|
'2ee659ce' => array(
|
||||||
'javelin-install',
|
'javelin-install',
|
||||||
),
|
),
|
||||||
'311eae46' => array(
|
|
||||||
'javelin-dom',
|
|
||||||
'javelin-util',
|
|
||||||
'javelin-stratcom',
|
|
||||||
'javelin-install',
|
|
||||||
'javelin-aphlict',
|
|
||||||
'javelin-workflow',
|
|
||||||
'javelin-router',
|
|
||||||
'javelin-behavior-device',
|
|
||||||
'javelin-vector',
|
|
||||||
),
|
|
||||||
'31420f77' => array(
|
'31420f77' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
),
|
),
|
||||||
|
@ -1166,6 +1141,20 @@ 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',
|
||||||
|
@ -1284,6 +1273,17 @@ return array(
|
||||||
'javelin-uri',
|
'javelin-uri',
|
||||||
'phabricator-notification',
|
'phabricator-notification',
|
||||||
),
|
),
|
||||||
|
'4d863052' => array(
|
||||||
|
'javelin-dom',
|
||||||
|
'javelin-util',
|
||||||
|
'javelin-stratcom',
|
||||||
|
'javelin-install',
|
||||||
|
'javelin-aphlict',
|
||||||
|
'javelin-workflow',
|
||||||
|
'javelin-router',
|
||||||
|
'javelin-behavior-device',
|
||||||
|
'javelin-vector',
|
||||||
|
),
|
||||||
'4e3e79a6' => array(
|
'4e3e79a6' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
|
@ -1409,13 +1409,6 @@ return array(
|
||||||
'javelin-workflow',
|
'javelin-workflow',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
),
|
),
|
||||||
'674e335f' => array(
|
|
||||||
'javelin-install',
|
|
||||||
'javelin-util',
|
|
||||||
'javelin-websocket',
|
|
||||||
'javelin-leader',
|
|
||||||
'javelin-json',
|
|
||||||
),
|
|
||||||
'680ea2c8' => array(
|
'680ea2c8' => array(
|
||||||
'javelin-install',
|
'javelin-install',
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
|
@ -2127,6 +2120,13 @@ return array(
|
||||||
'javelin-dom',
|
'javelin-dom',
|
||||||
'phabricator-draggable-list',
|
'phabricator-draggable-list',
|
||||||
),
|
),
|
||||||
|
'e1d4b11a' => array(
|
||||||
|
'javelin-install',
|
||||||
|
'javelin-util',
|
||||||
|
'javelin-websocket',
|
||||||
|
'javelin-leader',
|
||||||
|
'javelin-json',
|
||||||
|
),
|
||||||
'e1ff79b1' => array(
|
'e1ff79b1' => array(
|
||||||
'javelin-behavior',
|
'javelin-behavior',
|
||||||
'javelin-stratcom',
|
'javelin-stratcom',
|
||||||
|
|
|
@ -47,6 +47,7 @@ final class PhabricatorNotificationIndividualController
|
||||||
'title' => $data['title'],
|
'title' => $data['title'],
|
||||||
'body' => $data['body'],
|
'body' => $data['body'],
|
||||||
'content' => hsprintf('%s', $content),
|
'content' => hsprintf('%s', $content),
|
||||||
|
'uniqueID' => 'story/'.$story->getChronologicalKey(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return id(new AphrontAjaxResponse())->setContent($response);
|
return id(new AphrontAjaxResponse())->setContent($response);
|
||||||
|
|
|
@ -29,6 +29,7 @@ JX.install('Aphlict', {
|
||||||
this._uri = uri;
|
this._uri = uri;
|
||||||
this._subscriptions = subscriptions;
|
this._subscriptions = subscriptions;
|
||||||
this._setStatus('setup');
|
this._setStatus('setup');
|
||||||
|
this._startTime = new Date().getTime();
|
||||||
|
|
||||||
JX.Aphlict._instance = this;
|
JX.Aphlict._instance = this;
|
||||||
},
|
},
|
||||||
|
@ -42,6 +43,7 @@ JX.install('Aphlict', {
|
||||||
_status: null,
|
_status: null,
|
||||||
_isReconnect: false,
|
_isReconnect: false,
|
||||||
_keepaliveInterval: false,
|
_keepaliveInterval: false,
|
||||||
|
_startTime: null,
|
||||||
|
|
||||||
start: function() {
|
start: function() {
|
||||||
JX.Leader.listen('onBecomeLeader', JX.bind(this, this._lead));
|
JX.Leader.listen('onBecomeLeader', JX.bind(this, this._lead));
|
||||||
|
@ -121,8 +123,22 @@ JX.install('Aphlict', {
|
||||||
},
|
},
|
||||||
|
|
||||||
replay: function() {
|
replay: function() {
|
||||||
|
var age = 60000;
|
||||||
|
|
||||||
|
// If the page was loaded a few moments ago, only query for recent
|
||||||
|
// history. This keeps us from replaying events over and over again as
|
||||||
|
// a user browses normally.
|
||||||
|
|
||||||
|
// Allow a small margin of error for the actual page load time. It's
|
||||||
|
// also fine to replay a notification which the user saw for a brief
|
||||||
|
// moment on the previous page.
|
||||||
|
var extra_time = 500;
|
||||||
|
var now = new Date().getTime();
|
||||||
|
|
||||||
|
age = Math.min(extra_time + (now - this._startTime), age);
|
||||||
|
|
||||||
var replay = {
|
var replay = {
|
||||||
age: 60000
|
age: age
|
||||||
};
|
};
|
||||||
|
|
||||||
JX.Leader.broadcast(null, {type: 'aphlict.replay', data: replay});
|
JX.Leader.broadcast(null, {type: 'aphlict.replay', data: replay});
|
||||||
|
|
|
@ -66,7 +66,9 @@ JX.behavior('aphlict-listen', function(config) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JX.Leader.broadcast(null, {
|
JX.Leader.broadcast(
|
||||||
|
response.uniqueID,
|
||||||
|
{
|
||||||
type: 'notification.individual',
|
type: 'notification.individual',
|
||||||
data: response
|
data: response
|
||||||
});
|
});
|
||||||
|
|
|
@ -245,6 +245,10 @@ JX.install('ConpherenceThreadManager', {
|
||||||
'aphlict-reconnect',
|
'aphlict-reconnect',
|
||||||
null,
|
null,
|
||||||
JX.bind(this, function() {
|
JX.bind(this, function() {
|
||||||
|
if (!this._loadedThreadPHID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._updateThread();
|
this._updateThread();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue