1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00

Make id/phid Conpherence stuff more consistent

Summary:
Currently, `selected_conpherence_id` is actually a PHID. Instead, use ids everywhere.

Also, use replaceState instead of pushState. This means "back" takes you out of conpherence (not back to the last thread you looked at) but I think that's more consistent with user expectation.

Test Plan: Loaded thread list, loaded specific thread.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D5503
This commit is contained in:
epriestley 2013-04-01 12:44:00 -07:00
parent 1fd063277b
commit 787cc1dd82
4 changed files with 26 additions and 23 deletions

View file

@ -198,7 +198,6 @@ abstract class ConpherenceController extends PhabricatorController {
->setMetadata( ->setMetadata(
array( array(
'id' => $conpherence->getID(), 'id' => $conpherence->getID(),
'phid' => $conpherence->getPHID(),
)); ));
return $item; return $item;

View file

@ -27,7 +27,7 @@ final class ConpherenceListController extends
$conpherence_id = $this->getConpherenceID(); $conpherence_id = $this->getConpherenceID();
$current_selection_epoch = null; $current_selection_epoch = null;
$selected_phid = null; $conpherence = null;
if ($conpherence_id) { if ($conpherence_id) {
$conpherence = id(new ConpherenceThreadQuery()) $conpherence = id(new ConpherenceThreadQuery())
->setViewer($user) ->setViewer($user)
@ -40,7 +40,6 @@ final class ConpherenceListController extends
if ($conpherence->getTitle()) { if ($conpherence->getTitle()) {
$title = $conpherence->getTitle(); $title = $conpherence->getTitle();
} }
$selected_phid = $conpherence->getPHID();
$participant = $conpherence->getParticipant($user->getPHID()); $participant = $conpherence->getParticipant($user->getPHID());
$current_selection_epoch = $participant->getDateTouched(); $current_selection_epoch = $participant->getDateTouched();
@ -50,8 +49,11 @@ final class ConpherenceListController extends
$nav = $this->buildSideNavView(); $nav = $this->buildSideNavView();
$main_pane = id(new ConpherenceLayoutView()) $main_pane = id(new ConpherenceLayoutView())
->setBaseURI($this->getApplicationURI()) ->setBaseURI($this->getApplicationURI());
->setSelectedConpherencePHID($selected_phid);
if ($conpherence) {
$main_pane->setThread($conpherence);
}
$nav->appendChild( $nav->appendChild(
array( array(

View file

@ -2,7 +2,7 @@
final class ConpherenceLayoutView extends AphrontView { final class ConpherenceLayoutView extends AphrontView {
private $selectedConpherencePHID; private $thread;
private $baseURI; private $baseURI;
public function setBaseURI($base_uri) { public function setBaseURI($base_uri) {
@ -10,8 +10,8 @@ final class ConpherenceLayoutView extends AphrontView {
return $this; return $this;
} }
public function setSelectedConpherencePHID($selected_conpherence_phid) { public function setThread(ConpherenceThread $thread) {
$this->selectedConpherencePHID = $selected_conpherence_phid; $this->thread = $thread;
return $this; return $this;
} }
@ -26,8 +26,7 @@ final class ConpherenceLayoutView extends AphrontView {
'widgets_pane' => 'conpherence-widget-pane', 'widgets_pane' => 'conpherence-widget-pane',
'form_pane' => 'conpherence-form', 'form_pane' => 'conpherence-form',
'menu_pane' => 'conpherence-menu', 'menu_pane' => 'conpherence-menu',
'selected_conpherence_id' => $this->selectedConpherencePHID, 'selectedID' => ($this->thread ? $this->thread->getID() : null),
'fancy_ajax' => (bool)$this->selectedConpherencePHID,
)); ));
Javelin::initBehavior('conpherence-drag-and-drop-photo', Javelin::initBehavior('conpherence-drag-and-drop-photo',

View file

@ -1,4 +1,4 @@
/** <</**
* @provides javelin-behavior-conpherence-menu * @provides javelin-behavior-conpherence-menu
* @requires javelin-behavior * @requires javelin-behavior
* javelin-dom * javelin-dom
@ -16,6 +16,17 @@ JX.behavior('conpherence-menu', function(config) {
visible: null visible: null
}; };
function selectthreadid(id) {
var threads = JX.DOM.scry(document.body, 'a', 'conpherence-menu-click');
for (var ii = 0; ii < threads.length; ii++) {
var data = JX.Stratcom.getData(threads[ii]);
if (data.id == id) {
selectthread(threads[ii]);
return;
}
}
}
function selectthread(node) { function selectthread(node) {
if (node === thread.node) { if (node === thread.node) {
return; return;
@ -32,10 +43,9 @@ JX.behavior('conpherence-menu', function(config) {
thread.node = node; thread.node = node;
var data = JX.Stratcom.getData(node); var data = JX.Stratcom.getData(node);
thread.selected = data.phid; thread.selected = data.id;
// TODO: These URIs don't work yet, so don't push them until they do. JX.History.replace(config.base_uri + data.id + '/');
// JX.History.push(config.base_uri + 'view/' + data.id + '/');
redrawthread(); redrawthread();
} }
@ -155,15 +165,8 @@ JX.behavior('conpherence-menu', function(config) {
// If there's a currently visible thread, select it. // If there's a currently visible thread, select it.
if (config.selected_conpherence_id) { if (config.selectedID) {
var threads = JX.DOM.scry(document.body, 'a', 'conpherence-menu-click'); selectthreadid(config.selectedID);
for (var ii = 0; ii < threads.length; ii++) {
var data = JX.Stratcom.getData(threads[ii]);
if (data.phid == config.selected_conpherence_id) {
selectthread(threads[ii]);
break;
}
}
} }
}); });