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

Fix some issues where Conpherence would make to many draft requests

Summary:
A few minor fixes:

  - When we build a tag with `"meta" => null`, strip the attribute like we do for all other attributes. Previously, we would actually set the metadata to `null`. This happened with the Conpherence form.
  - Just respond to the draft request with an empty (but valid) response, instead of building a dialog.
  - `PhabricatorShapedRequest` is confusingly named and I should have caught this in review, but the basic shape of it is:
    - You make one object.
    - You call `trigger()` when stuff changes (e.g., a keystroke).
    - It manages making a small number of requests (e.g., one request after the user stops typing for a moment).
  - The way it was being used previously would incorrectly send a request for every keystroke.

I think I'm going to simplify `ShapedRequest` and merge it into some larger queue for T430.

Test Plan: Typed some text, no longer saw a flurry of requests. Reloaded page, still saw draft text.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran, chad

Differential Revision: https://secure.phabricator.com/D8380
This commit is contained in:
epriestley 2014-03-01 11:23:08 -08:00
parent b383d2c338
commit e556d20577
4 changed files with 39 additions and 30 deletions

View file

@ -348,7 +348,7 @@ return array(
'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => '845731b8',
'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18',
'rsrc/js/application/config/behavior-reorder-fields.js' => '938aed89',
'rsrc/js/application/conpherence/behavior-menu.js' => '7ff0b011',
'rsrc/js/application/conpherence/behavior-menu.js' => '7ee23816',
'rsrc/js/application/conpherence/behavior-pontificate.js' => '53f6f2dd',
'rsrc/js/application/conpherence/behavior-widget-pane.js' => 'd8ef8659',
'rsrc/js/application/countdown/timer.js' => '889c96f3',
@ -535,7 +535,7 @@ return array(
'javelin-behavior-audit-preview' => 'be81801d',
'javelin-behavior-balanced-payment-form' => '3b3e1664',
'javelin-behavior-config-reorder-fields' => '938aed89',
'javelin-behavior-conpherence-menu' => '7ff0b011',
'javelin-behavior-conpherence-menu' => '7ee23816',
'javelin-behavior-conpherence-pontificate' => '53f6f2dd',
'javelin-behavior-conpherence-widget-pane' => 'd8ef8659',
'javelin-behavior-countdown-timer' => '889c96f3',
@ -1225,6 +1225,13 @@ return array(
2 => 'javelin-util',
3 => 'phabricator-shaped-request',
),
'62e18640' =>
array(
0 => 'javelin-install',
1 => 'javelin-util',
2 => 'javelin-dom',
3 => 'javelin-typeahead-normalizer',
),
'6453c869' =>
array(
0 => 'javelin-install',
@ -1258,13 +1265,6 @@ return array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
),
'62e18640' =>
array(
0 => 'javelin-install',
1 => 'javelin-util',
2 => 'javelin-dom',
3 => 'javelin-typeahead-normalizer',
),
'75903ee1' =>
array(
0 => 'javelin-behavior',
@ -1313,12 +1313,7 @@ return array(
0 => 'herald-rule-editor',
1 => 'javelin-behavior',
),
'7ee2b591' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-history',
),
'7ff0b011' =>
'7ee23816' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
@ -1330,6 +1325,11 @@ return array(
7 => 'javelin-vector',
8 => 'phabricator-shaped-request',
),
'7ee2b591' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-history',
),
'82947dda' =>
array(
0 => 'javelin-behavior',

View file

@ -51,7 +51,7 @@ final class ConpherenceUpdateController
$conpherence->getPHID());
$draft->setDraft($request->getStr('text'));
$draft->replaceOrDelete();
break;
return new AphrontAjaxResponse();
case ConpherenceUpdateActions::MESSAGE:
$message = $request->getStr('text');
$xactions = $editor->generateTransactionsFromText(

View file

@ -11,13 +11,17 @@ function javelin_tag(
foreach ($attributes as $k => $v) {
switch ($k) {
case 'sigil':
$attributes['data-sigil'] = $v;
if ($v !== null) {
$attributes['data-sigil'] = $v;
}
unset($attributes[$k]);
break;
case 'meta':
$response = CelerityAPI::getStaticResourceResponse();
$id = $response->addMetadata($v);
$attributes['data-meta'] = $id;
if ($v !== null) {
$response = CelerityAPI::getStaticResourceResponse();
$id = $response->addMetadata($v);
$attributes['data-meta'] = $id;
}
unset($attributes[$k]);
break;
case 'mustcapture':

View file

@ -530,16 +530,21 @@ JX.behavior('conpherence-menu', function(config) {
var onkeydownDraft = function (e) {
var form = e.getNode('tag:form');
var uri = config.baseURI + 'update/' + _thread.selected + '/';
var draftRequest = new JX.PhabricatorShapedRequest(
uri,
JX.bag,
function () {
var data = JX.DOM.convertFormToDictionary(form);
data.action = 'draft';
return data;
});
draftRequest.start();
var data = e.getNodeData('tag:form');
if (!data.preview) {
var uri = config.baseURI + 'update/' + _thread.selected + '/';
data.preview = new JX.PhabricatorShapedRequest(
uri,
JX.bag,
function () {
var data = JX.DOM.convertFormToDictionary(form);
data.action = 'draft';
return data;
});
}
data.preview.trigger();
};
JX.Stratcom.listen(