1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-05 03:18:25 +01:00

Conpherence - continue the load less quest

Summary: basically makes it so we only really load what we need from the server for any particular update action. the javascript thus then has some things deleted from it. made a spot or two ready for when the pertinent UI won't be there as well. also added a feature in javascript -- updating the document title to the current conpherence title.  Ref T2867 T2399

Test Plan: played with conpherence for quite a bit.

Reviewers: epriestley, chad

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2867

Differential Revision: https://secure.phabricator.com/D5625
This commit is contained in:
Bob Trahan 2013-04-10 11:37:04 -07:00
parent 7e93e9fbe9
commit 8ede9dc061
8 changed files with 111 additions and 102 deletions

View file

@ -1282,7 +1282,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-conpherence-menu' =>
array(
'uri' => '/res/257f200d/rsrc/js/application/conpherence/behavior-menu.js',
'uri' => '/res/7021ec83/rsrc/js/application/conpherence/behavior-menu.js',
'type' => 'js',
'requires' =>
array(
@ -1299,7 +1299,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-conpherence-pontificate' =>
array(
'uri' => '/res/91d6418d/rsrc/js/application/conpherence/behavior-pontificate.js',
'uri' => '/res/b45269fc/rsrc/js/application/conpherence/behavior-pontificate.js',
'type' => 'js',
'requires' =>
array(
@ -1313,7 +1313,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-conpherence-widget-pane' =>
array(
'uri' => '/res/0c0fc5ef/rsrc/js/application/conpherence/behavior-widget-pane.js',
'uri' => '/res/32f4bf14/rsrc/js/application/conpherence/behavior-widget-pane.js',
'type' => 'js',
'requires' =>
array(

View file

@ -252,6 +252,7 @@ phutil_register_library_map(array(
'ConpherenceTransactionQuery' => 'applications/conpherence/query/ConpherenceTransactionQuery.php',
'ConpherenceTransactionType' => 'applications/conpherence/constants/ConpherenceTransactionType.php',
'ConpherenceTransactionView' => 'applications/conpherence/view/ConpherenceTransactionView.php',
'ConpherenceUpdateActions' => 'applications/conpherence/constants/ConpherenceUpdateActions.php',
'ConpherenceUpdateController' => 'applications/conpherence/controller/ConpherenceUpdateController.php',
'ConpherenceViewController' => 'applications/conpherence/controller/ConpherenceViewController.php',
'ConpherenceWidgetController' => 'applications/conpherence/controller/ConpherenceWidgetController.php',
@ -1983,6 +1984,7 @@ phutil_register_library_map(array(
'ConpherenceTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'ConpherenceTransactionType' => 'ConpherenceConstants',
'ConpherenceTransactionView' => 'AphrontView',
'ConpherenceUpdateActions' => 'ConpherenceConstants',
'ConpherenceUpdateController' => 'ConpherenceController',
'ConpherenceViewController' => 'ConpherenceController',
'ConpherenceWidgetController' => 'ConpherenceController',

View file

@ -0,0 +1,10 @@
<?php
final class ConpherenceUpdateActions extends ConpherenceConstants {
const METADATA = 'metadata';
const MESSAGE = 'message';
const ADD_PERSON = 'add_person';
const REMOVE_PERSON = 'remove_person';
const NOTIFICATIONS = 'notifications';
}

View file

@ -36,7 +36,7 @@ final class ConpherenceUpdateController
->executeOne();
$supported_formats = PhabricatorFile::getTransformableImageFormats();
$action = $request->getStr('action', 'metadata');
$action = $request->getStr('action', ConpherenceUpdateActions::METADATA);
$latest_transaction_id = null;
$response_mode = 'ajax';
$error_view = null;
@ -54,13 +54,13 @@ final class ConpherenceUpdateController
->setActor($user);
switch ($action) {
case 'message':
case ConpherenceUpdateActions::MESSAGE:
$message = $request->getStr('text');
$xactions = $editor->generateTransactionsFromText(
$conpherence,
$message);
break;
case 'add_person':
case ConpherenceUpdateActions::ADD_PERSON:
$xactions = array();
$person_tokenizer = $request->getArr('add_person');
$person_phid = reset($person_tokenizer);
@ -71,7 +71,7 @@ final class ConpherenceUpdateController
->setNewValue(array('+' => array($person_phid)));
}
break;
case 'remove_person':
case ConpherenceUpdateActions::REMOVE_PERSON:
$xactions = array();
if (!$request->isContinueRequest()) {
// do nothing; we'll display a confirmation dialogue instead
@ -86,7 +86,7 @@ final class ConpherenceUpdateController
$response_mode = 'go-home';
}
break;
case 'notifications':
case ConpherenceUpdateActions::NOTIFICATIONS:
$notifications = $request->getStr('notifications');
$participant = $conpherence->getParticipant($user->getPHID());
$participant->setSettings(array('notifications' => $notifications));
@ -97,7 +97,7 @@ final class ConpherenceUpdateController
return id(new AphrontAjaxResponse())
->setContent($result);
break;
case 'metadata':
case ConpherenceUpdateActions::METADATA:
$xactions = array();
$top = $request->getInt('image_y');
$left = $request->getInt('image_x');
@ -193,6 +193,7 @@ final class ConpherenceUpdateController
case 'ajax':
$latest_transaction_id = $request->getInt('latest_transaction_id');
$content = $this->loadAndRenderUpdates(
$action,
$conpherence_id,
$latest_transaction_id);
return id(new AphrontAjaxResponse())
@ -219,10 +220,10 @@ final class ConpherenceUpdateController
}
switch ($action) {
case 'remove_person':
case ConpherenceUpdateActions::REMOVE_PERSON:
$dialogue = $this->renderRemovePersonDialogue($conpherence);
break;
case 'metadata':
case ConpherenceUpdateActions::METADATA:
default:
$dialogue = $this->renderMetadataDialogue($conpherence, $error_view);
break;
@ -318,39 +319,77 @@ final class ConpherenceUpdateController
}
private function loadAndRenderUpdates(
$action,
$conpherence_id,
$latest_transaction_id) {
$need_header_pics = false;
$need_widget_data = false;
$need_transactions = false;
switch ($action) {
case ConpherenceUpdateActions::METADATA:
$need_header_pics = true;
$need_transactions = true;
break;
case ConpherenceUpdateActions::MESSAGE:
case ConpherenceUpdateActions::ADD_PERSON:
$need_transactions = true;
$need_widget_data = true;
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
case ConpherenceUpdateActions::NOTIFICATIONS:
default:
break;
}
$user = $this->getRequest()->getUser();
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->setAfterMessageID($latest_transaction_id)
->needHeaderPics(true)
->needWidgetData(true)
->needTransactions(true)
->needHeaderPics($need_header_pics)
->needWidgetData($need_widget_data)
->needTransactions($need_transactions)
->withIDs(array($conpherence_id))
->executeOne();
$data = $this->renderConpherenceTransactions($conpherence);
$rendered_transactions = $data['transactions'];
$new_latest_transaction_id = $data['latest_transaction_id'];
$nav_item = id(new ConpherenceThreadListView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->renderSingleThread($conpherence);
$header = $this->buildHeaderPaneContent($conpherence);
if ($need_transactions) {
$data = $this->renderConpherenceTransactions($conpherence);
} else {
$data = array();
}
$rendered_transactions = idx($data, 'transactions');
$new_latest_transaction_id = idx($data, 'latest_transaction_id');
$widget_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
$file_widget = id(new ConpherenceFileWidgetView())
->setUser($this->getRequest()->getUser())
->setConpherence($conpherence)
->setUpdateURI($widget_uri);
$people_widget = id(new ConpherencePeopleWidgetView())
->setUser($user)
->setConpherence($conpherence)
->setUpdateURI($widget_uri);
$nav_item = null;
$header = null;
$people_widget = null;
$file_widget = null;
switch ($action) {
case ConpherenceUpdateActions::METADATA:
$header = $this->buildHeaderPaneContent($conpherence);
$nav_item = id(new ConpherenceThreadListView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->renderSingleThread($conpherence);
break;
case ConpherenceUpdateActions::MESSAGE:
$file_widget = id(new ConpherenceFileWidgetView())
->setUser($this->getRequest()->getUser())
->setConpherence($conpherence)
->setUpdateURI($widget_uri);
break;
case ConpherenceUpdateActions::ADD_PERSON:
$people_widget = id(new ConpherencePeopleWidgetView())
->setUser($user)
->setConpherence($conpherence)
->setUpdateURI($widget_uri);
break;
case ConpherenceUpdateActions::REMOVE_PERSON:
case ConpherenceUpdateActions::NOTIFICATIONS:
default:
break;
}
$content = array(
'transactions' => $rendered_transactions,
@ -358,9 +397,10 @@ final class ConpherenceUpdateController
'nav_item' => hsprintf('%s', $nav_item),
'conpherence_phid' => $conpherence->getPHID(),
'header' => hsprintf('%s', $header),
'file_widget' => $file_widget->render(),
'people_widget' => $people_widget->render()
'file_widget' => $file_widget ? $file_widget->render() : null,
'people_widget' => $people_widget ? $people_widget->render() : null,
);
return $content;
}

View file

@ -79,6 +79,7 @@ final class ConpherenceThreadListView extends AphrontView {
->addSigil('conpherence-menu-click')
->setMetadata(
array(
'title' => $title,
'id' => $thread->getID(),
));
}

View file

@ -47,6 +47,8 @@ JX.behavior('conpherence-menu', function(config) {
thread.selected = data.id;
JX.History.replace(config.base_uri + data.id + '/');
document.title = data.title;
redrawthread();
}
@ -139,16 +141,13 @@ JX.behavior('conpherence-menu', function(config) {
var form = JX.DOM.find(root, 'form', 'conpherence-pontificate');
var data = e.getNodeData('conpherence-edit-metadata');
var header = JX.DOM.find(root, 'div', 'conpherence-header');
var peopleWidget = null;
try {
peopleWidget = JX.DOM.find(root, 'div', 'widgets-people');
} catch (ex) {
// Ignore; maybe no people widget
}
var messages = JX.DOM.find(root, 'div', 'conpherence-messages');
new JX.Workflow.newFromForm(form, data)
.setHandler(JX.bind(this, function(r) {
// update the header
JX.DOM.appendContent(messages, JX.$H(r.transactions));
messages.scrollTop = messages.scrollHeight;
JX.DOM.setContent(
header,
JX.$H(r.header)
@ -168,14 +167,6 @@ JX.behavior('conpherence-menu', function(config) {
} catch (ex) {
// Ignore; this view may not have a menu.
}
if (peopleWidget) {
// update the people widget
JX.DOM.setContent(
peopleWidget,
JX.$H(r.people_widget)
);
}
}))
.start();
});

View file

@ -15,40 +15,17 @@ JX.behavior('conpherence-pontificate', function(config) {
var root = e.getNode('conpherence-layout');
var messages = JX.DOM.find(root, 'div', 'conpherence-messages');
var header = JX.DOM.find(root, 'div', 'conpherence-header');
var fileWidget = null;
try {
fileWidget = JX.DOM.find(root, 'div', 'widgets-files');
} catch (ex) {
// Ignore; maybe no files widget
}
var peopleWidget = null;
try {
peopleWidget = JX.DOM.find(root, 'div', 'widgets-people');
} catch (ex) {
// Ignore; maybe no peoples widget
}
JX.Workflow.newFromForm(form)
.setHandler(JX.bind(this, function(r) {
// add the new transactions, probably just our post but who knows
JX.DOM.appendContent(messages, JX.$H(r.transactions));
messages.scrollTop = messages.scrollHeight;
JX.DOM.setContent(header, JX.$H(r.header));
try {
var node = JX.$(r.conpherence_phid + '-nav-item');
JX.DOM.replace(
node,
JX.$H(r.nav_item));
JX.Stratcom.invoke(
'conpherence-selectthread',
null,
{ id : r.conpherence_phid + '-nav-item' }
);
} catch (ex) {
// Ignore; this view may not have a menu.
}
if (fileWidget) {
JX.DOM.setContent(
@ -57,13 +34,6 @@ JX.behavior('conpherence-pontificate', function(config) {
);
}
if (peopleWidget) {
JX.DOM.setContent(
peopleWidget,
JX.$H(r.people_widget)
);
}
var inputs = JX.DOM.scry(form, 'input');
for (var ii = 0; ii < inputs.length; ii++) {
if (inputs[ii].name == 'latest_transaction_id') {
@ -74,6 +44,16 @@ JX.behavior('conpherence-pontificate', function(config) {
var textarea = JX.DOM.find(form, 'textarea');
textarea.value = '';
try {
JX.Stratcom.invoke(
'conpherence-selectthread',
null,
{ id : r.conpherence_phid + '-nav-item' }
);
} catch (ex) {
// Ignore; this view may not have a menu.
}
}))
.start();
};

View file

@ -49,8 +49,11 @@ JX.behavior('conpherence-widget-pane', function(config) {
var form = e.getNode('tag:form');
var data = e.getNodeData('add-person');
var peopleRoot = e.getNode('widgets-people');
var messages = JX.DOM.find(root, 'div', 'conpherence-messages');
var header = JX.DOM.find(root, 'div', 'conpherence-header');
var messages = null;
try {
messages = JX.DOM.find(root, 'div', 'conpherence-messages');
} catch (ex) {
}
var latestTransactionData = JX.Stratcom.getData(
JX.DOM.find(
root,
@ -60,29 +63,11 @@ JX.behavior('conpherence-widget-pane', function(config) {
data.latest_transaction_id = latestTransactionData.id;
JX.Workflow.newFromForm(form, data)
.setHandler(JX.bind(this, function (r) {
// update the transactions
JX.DOM.appendContent(messages, JX.$H(r.transactions));
messages.scrollTop = messages.scrollHeight;
try {
JX.DOM.replace(
JX.$(r.conpherence_phid + '-nav-item'),
JX.$H(r.nav_item));
JX.Stratcom.invoke(
'conpherence-selectthread',
null,
{ id : r.conpherence_phid + '-nav-item' }
);
} catch (ex) {
// Ignore; this view may not have a menu.
if (messages) {
JX.DOM.appendContent(messages, JX.$H(r.transactions));
messages.scrollTop = messages.scrollHeight;
}
// update the header
JX.DOM.setContent(
header,
JX.$H(r.header)
);
// update the people widget
JX.DOM.setContent(
peopleRoot,