Centralised function for the sort order

This commit is contained in:
Michael 2023-09-09 13:48:41 +00:00
parent 19dfdbc03f
commit ab235e24ad
2 changed files with 13 additions and 20 deletions

View File

@ -238,15 +238,7 @@ class Network extends Timeline
$o .= Profile::getEventsReminderHTML(); $o .= Profile::getEventsReminderHTML();
} }
if (self::$order === 'received') { $o .= $this->conversation->render($items, Conversation::MODE_NETWORK, false, false, $this->getOrder(), $this->session->getLocalUserId());
$ordering = '`received`';
} elseif (self::$order === 'created') {
$ordering = '`created`';
} else {
$ordering = '`commented`';
}
$o .= $this->conversation->render($items, Conversation::MODE_NETWORK, false, false, $ordering, $this->session->getLocalUserId());
if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) { if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) {
$o .= HTML::scrollLoader(); $o .= HTML::scrollLoader();
@ -265,6 +257,17 @@ class Network extends Timeline
return $o; return $o;
} }
protected function getOrder(): string
{
if (self::$order === 'received') {
return '`received`';
} elseif (self::$order === 'created') {
return '`created`';
} else {
return '`commented`';
}
}
/** /**
* Sets items as seen * Sets items as seen
* *

View File

@ -43,17 +43,7 @@ class Network extends NetworkModule
System::htmlUpdateExit($o); System::htmlUpdateExit($o);
} }
$items = $this->getItems(); $o = $this->conversation->render($this->getItems(), Conversation::MODE_NETWORK, $profile_uid, false, $this->getOrder(), $this->session->getLocalUserId());
if (self::$order === 'received') {
$ordering = '`received`';
} elseif (self::$order === 'created') {
$ordering = '`created`';
} else {
$ordering = '`commented`';
}
$o = $this->conversation->render($items, Conversation::MODE_NETWORK, $profile_uid, false, $ordering, $this->session->getLocalUserId());
System::htmlUpdateExit($o); System::htmlUpdateExit($o);
} }