Simplify network update
This commit is contained in:
parent
d1c00cf1f6
commit
19dfdbc03f
|
@ -151,11 +151,7 @@ class Network extends Timeline
|
||||||
$this->page['aside'] .= Widget\SavedSearches::getHTML($this->args->getQueryString());
|
$this->page['aside'] .= Widget\SavedSearches::getHTML($this->args->getQueryString());
|
||||||
$this->page['aside'] .= Widget::fileAs('filed', '');
|
$this->page['aside'] .= Widget::fileAs('filed', '');
|
||||||
|
|
||||||
// Fetch a page full of parent items for this page
|
$items = $this->getItems();
|
||||||
$params = ['limit' => $this->itemsPerPage];
|
|
||||||
$table = 'network-thread-view';
|
|
||||||
|
|
||||||
$items = $this->getItems($table, $params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
|
if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll') && ($_GET['mode'] ?? '') != 'minimal') {
|
||||||
|
@ -383,9 +379,9 @@ class Network extends Timeline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getItems(string $table, array $params, array $conditionFields = [])
|
protected function getItems()
|
||||||
{
|
{
|
||||||
$conditionFields['uid'] = $this->session->getLocalUserId();
|
$conditionFields = ['uid' => $this->session->getLocalUserId()];
|
||||||
$conditionStrings = [];
|
$conditionStrings = [];
|
||||||
|
|
||||||
if (!is_null($this->accountType)) {
|
if (!is_null($this->accountType)) {
|
||||||
|
@ -456,6 +452,8 @@ class Network extends Timeline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$params = ['limit' => $this->itemsPerPage];
|
||||||
|
|
||||||
if (isset($this->minId) && !isset($this->maxId)) {
|
if (isset($this->minId) && !isset($this->maxId)) {
|
||||||
// min_id quirk: querying in reverse order with min_id gets the most recent rows, regardless of how close
|
// min_id quirk: querying in reverse order with min_id gets the most recent rows, regardless of how close
|
||||||
// they are to min_id. We change the query ordering to get the expected data, and we need to reverse the
|
// they are to min_id. We change the query ordering to get the expected data, and we need to reverse the
|
||||||
|
@ -465,7 +463,7 @@ class Network extends Timeline
|
||||||
$params['order'] = [self::$order => true];
|
$params['order'] = [self::$order => true];
|
||||||
}
|
}
|
||||||
|
|
||||||
$items = DBA::selectToArray($table, [], DBA::mergeConditions($conditionFields, $conditionStrings), $params);
|
$items = DBA::selectToArray('network-thread-view', [], DBA::mergeConditions($conditionFields, $conditionStrings), $params);
|
||||||
|
|
||||||
// min_id quirk, continued
|
// min_id quirk, continued
|
||||||
if (isset($this->minId) && !isset($this->maxId)) {
|
if (isset($this->minId) && !isset($this->maxId)) {
|
||||||
|
|
|
@ -23,8 +23,6 @@ namespace Friendica\Module\Update;
|
||||||
|
|
||||||
use Friendica\Content\Conversation;
|
use Friendica\Content\Conversation;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Model\Item;
|
|
||||||
use Friendica\Model\Post;
|
|
||||||
use Friendica\Module\Conversation\Network as NetworkModule;
|
use Friendica\Module\Conversation\Network as NetworkModule;
|
||||||
|
|
||||||
class Network extends NetworkModule
|
class Network extends NetworkModule
|
||||||
|
@ -45,30 +43,7 @@ class Network extends NetworkModule
|
||||||
System::htmlUpdateExit($o);
|
System::htmlUpdateExit($o);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($request['item'])) {
|
$items = $this->getItems();
|
||||||
$item = Post::selectFirst(['parent'], ['id' => $request['item']]);
|
|
||||||
$parent = $item['parent'] ?? 0;
|
|
||||||
} else {
|
|
||||||
$parent = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$conditionFields = [];
|
|
||||||
if (!empty($parent)) {
|
|
||||||
// Load only a single thread
|
|
||||||
$conditionFields['parent'] = $parent;
|
|
||||||
} elseif (self::$order === 'received') {
|
|
||||||
// Only load new toplevel posts
|
|
||||||
$conditionFields['unseen'] = true;
|
|
||||||
$conditionFields['gravity'] = Item::GRAVITY_PARENT;
|
|
||||||
} else {
|
|
||||||
// Load all unseen items
|
|
||||||
$conditionFields['unseen'] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = ['limit' => $this->itemsPerPage];
|
|
||||||
$table = 'network-thread-view';
|
|
||||||
|
|
||||||
$items = $this->getItems($table, $params, $conditionFields);
|
|
||||||
|
|
||||||
if (self::$order === 'received') {
|
if (self::$order === 'received') {
|
||||||
$ordering = '`received`';
|
$ordering = '`received`';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user