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

Make workboard real-time updates mostly work

Summary:
Depends on D20654. Ref T4900. When a task is edited, emit a "workboards" event for all boards it appears on (in a future change, this should also include all boards it //previously// appeared on, and all parents of both sets of boards -- but I'm just getting things working for now).

When we receive a "workboards" event, check if the visible board should be updated.

Aphlict has a complicated intra-window leader/follower election system which could let us process this update event exactly once no matter how many windows a user has open with the same workboard. I'm not trying to do any of this since it seems fairly rare. It makes sense for events like "you have new notifications" where we don't want to generate 100 Ajax calls if the user has 100 windows open, but very few users seem likely to have 100 copies of the same workboard open.

Test Plan:
  - Ran `bin/aphlict debug`.
  - Opened workboard A in two windows, X and Y.
  - Edited and moved tasks in window X.
  - Saw "workboards" messages in the Aphlict log.
  - Saw window Y update in nearly-real-time (locally, this is fast enough that it feels instantaneous).

Then:

  - Stopped the Aphlcit server.
  - Edited a task.
  - Started the Aphlict server.
  - Saw window Y update after a few moments (i.e., update in response to a reconnect).

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T4900

Differential Revision: https://secure.phabricator.com/D20656
This commit is contained in:
epriestley 2019-07-17 12:23:32 -07:00
parent 9ab5f59ca2
commit 17caecdda3
3 changed files with 73 additions and 14 deletions

View file

@ -412,7 +412,7 @@ return array(
'rsrc/js/application/phortune/phortune-credit-card-form.js' => 'd12d214f',
'rsrc/js/application/policy/behavior-policy-control.js' => '0eaa33a9',
'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '9347f172',
'rsrc/js/application/projects/WorkboardBoard.js' => '19df903f',
'rsrc/js/application/projects/WorkboardBoard.js' => '75727403',
'rsrc/js/application/projects/WorkboardCard.js' => '0392a5d8',
'rsrc/js/application/projects/WorkboardCardTemplate.js' => '84f82dad',
'rsrc/js/application/projects/WorkboardColumn.js' => 'c3d24e63',
@ -743,7 +743,7 @@ return array(
'javelin-view-renderer' => '9aae2b66',
'javelin-view-visitor' => '308f9fe4',
'javelin-websocket' => 'fdc13e4e',
'javelin-workboard-board' => '19df903f',
'javelin-workboard-board' => '75727403',
'javelin-workboard-card' => '0392a5d8',
'javelin-workboard-card-template' => '84f82dad',
'javelin-workboard-column' => 'c3d24e63',
@ -1030,18 +1030,6 @@ return array(
'17b71bbc' => array(
'phui-theme-css',
),
'19df903f' => array(
'javelin-install',
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-workflow',
'phabricator-draggable-list',
'javelin-workboard-column',
'javelin-workboard-header-template',
'javelin-workboard-card-template',
'javelin-workboard-order-template',
),
'1b6acc2a' => array(
'javelin-magical-init',
'javelin-util',
@ -1561,6 +1549,18 @@ return array(
'javelin-uri',
'javelin-request',
),
75727403 => array(
'javelin-install',
'javelin-dom',
'javelin-util',
'javelin-stratcom',
'javelin-workflow',
'phabricator-draggable-list',
'javelin-workboard-column',
'javelin-workboard-header-template',
'javelin-workboard-card-template',
'javelin-workboard-order-template',
),
'78bc5d94' => array(
'javelin-behavior',
'javelin-uri',

View file

@ -859,4 +859,33 @@ final class ManiphestTransactionEditor
return array_values($phid_list);
}
protected function didApplyTransactions($object, array $xactions) {
// TODO: This should include projects which the object was previously
// associated with but no longer is (so it can be removed from those
// boards) but currently does not.
$edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(array($object->getPHID()))
->withEdgeTypes(
array(
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
));
$edge_query->execute();
$project_phids = $edge_query->getDestinationPHIDs();
if ($project_phids) {
$data = array(
'type' => 'workboards',
'subscribers' => $project_phids,
);
PhabricatorNotificationClient::tryToPostMessage($data);
}
return $xactions;
}
}

View file

@ -136,6 +136,36 @@ JX.install('WorkboardBoard', {
.setHandler(on_reload)
.register();
var board_phid = this.getPHID();
JX.Stratcom.listen('aphlict-server-message', null, function(e) {
var message = e.getData();
if (message.type != 'workboards') {
return;
}
// Check if this update notification is about the currently visible
// board. If it is, update the board state.
var found_board = false;
for (var ii = 0; ii < message.subscribers.length; ii++) {
var subscriber_phid = message.subscribers[ii];
if (subscriber_phid === board_phid) {
found_board = true;
break;
}
}
if (found_board) {
on_reload();
}
});
JX.Stratcom.listen('aphlict-reconnect', null, function(e) {
on_reload();
});
for (var k in this._columns) {
this._columns[k].redraw();
}