1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 02:02:41 +01:00
phorge-phorge/src/applications/conpherence/controller/ConpherenceListController.php
epriestley acb32a6b72 Fill thread list on thread view in Conpherence
Summary:
When we access `/conpherence/view/2/` on the desktop, load the thread on the initial response and ajax in the thread list. Basically, the idea is:

  - When we load the thread list, an individual thread, or the widget panel, we send back the piece the user asked for in the response.
  - On mobile, we stop there: we don't ajax in anything else, and just hide the other parts of the layout.
  - On Desktop, we fill out the other layout components via Ajax.

Ref T2421.

Test Plan: Hit `/conpherence/view/2/`, got a full page.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2421

Differential Revision: https://secure.phabricator.com/D5507
2013-04-01 12:52:56 -07:00

78 lines
1.9 KiB
PHP

<?php
/**
* @group conpherence
*/
final class ConpherenceListController
extends ConpherenceController {
private $conpherenceID;
public function setConpherenceID($conpherence_id) {
$this->conpherenceID = $conpherence_id;
return $this;
}
public function getConpherenceID() {
return $this->conpherenceID;
}
public function willProcessRequest(array $data) {
$this->setConpherenceID(idx($data, 'id'));
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$title = pht('Conpherence');
$conpherence_id = $this->getConpherenceID();
$current_selection_epoch = null;
$conpherence = null;
if ($conpherence_id) {
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($user)
->withIDs(array($conpherence_id))
->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
if ($conpherence->getTitle()) {
$title = $conpherence->getTitle();
}
$participant = $conpherence->getParticipant($user->getPHID());
$current_selection_epoch = $participant->getDateTouched();
}
list($unread, $read) = $this->loadStartingConpherences(
$current_selection_epoch);
$thread_view = id(new ConpherenceThreadListView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->setUnreadThreads($unread)
->setReadThreads($read);
if ($request->isAjax()) {
return id(new AphrontAjaxResponse())->setContent($thread_view);
}
$layout = id(new ConpherenceLayoutView())
->setBaseURI($this->getApplicationURI())
->setThreadView($thread_view)
->setRole('list');
if ($conpherence) {
$layout->setThread($conpherence);
}
return $this->buildApplicationPage(
$layout,
array(
'title' => $title,
'device' => true,
));
}
}