From: Michael Date: Sat, 9 Sep 2023 13:48:41 +0000 (+0000) Subject: Centralised function for the sort order X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ab235e24ad8ebf365d4466cc6c34f9b571bae467;p=friendica.git Centralised function for the sort order --- diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index b65910e01b..e99c015050 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -238,15 +238,7 @@ class Network extends Timeline $o .= Profile::getEventsReminderHTML(); } - if (self::$order === 'received') { - $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()); + $o .= $this->conversation->render($items, Conversation::MODE_NETWORK, false, false, $this->getOrder(), $this->session->getLocalUserId()); if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) { $o .= HTML::scrollLoader(); @@ -265,6 +257,17 @@ class Network extends Timeline 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 * diff --git a/src/Module/Update/Network.php b/src/Module/Update/Network.php index adb73141d6..59ab0e2eb1 100644 --- a/src/Module/Update/Network.php +++ b/src/Module/Update/Network.php @@ -43,17 +43,7 @@ class Network extends NetworkModule System::htmlUpdateExit($o); } - $items = $this->getItems(); - - 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()); + $o = $this->conversation->render($this->getItems(), Conversation::MODE_NETWORK, $profile_uid, false, $this->getOrder(), $this->session->getLocalUserId()); System::htmlUpdateExit($o); }