diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index f21b3816a..abe836f27 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -11,6 +11,7 @@ use Friendica\Content\Text\HTML; use Friendica\Core\ACL; use Friendica\Core\Hook; use Friendica\Core\Renderer; +use Friendica\Core\Session; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -282,7 +283,7 @@ class Network extends BaseModule self::$forumContactId = $parameters['contact_id'] ?? 0; - self::$selectedTab = DI::pConfig()->get(local_user(), 'network.view', 'selected_tab', ''); + self::$selectedTab = Session::get('network-tab', ''); if (!empty($get['star'])) { self::$selectedTab = 'star'; @@ -296,13 +297,18 @@ class Network extends BaseModule self::$selectedTab = $get['order']; } - DI::pConfig()->set(local_user(), 'network.view', 'selected_tab', self::$selectedTab); + Session::set('network-tab', self::$selectedTab); - self::$star = intval($get['star'] ?? 0); - self::$mention = intval($_GET['mention'] ?? 0); - self::$order = in_array(self::$selectedTab, ['received', 'commented', 'created', 'uriid']) ? self::$selectedTab : 'commented'; + self::$star = intval($get['star'] ?? 0); + self::$mention = intval($get['mention'] ?? 0); + self::$order = $get['order'] ?? Session::get('network-order', 'commented'); - self::$accountTypeString = $_GET['accounttype'] ?? $parameters['accounttype'] ?? ''; + self::$selectedTab = self::$selectedTab ?? self::$order; + + Session::set('network-tab', self::$selectedTab); + Session::set('network-order', self::$order); + + self::$accountTypeString = $get['accounttype'] ?? $parameters['accounttype'] ?? ''; self::$accountType = User::getAccountTypeByString(self::$accountTypeString); self::$network = $get['nets'] ?? ''; @@ -318,21 +324,21 @@ class Network extends BaseModule DI::config()->get('system', 'itemspage_network')); } - self::$min_id = $_GET['min_id'] ?? null; - self::$max_id = $_GET['max_id'] ?? null; + self::$min_id = $get['min_id'] ?? null; + self::$max_id = $get['max_id'] ?? null; - switch (self::$selectedTab) { + switch (self::$order) { case 'received': - self::$max_id = $_GET['last_received'] ?? self::$max_id; + self::$max_id = $get['last_received'] ?? self::$max_id; break; case 'commented': - self::$max_id = $_GET['last_commented'] ?? self::$max_id; + self::$max_id = $get['last_commented'] ?? self::$max_id; break; case 'created': - self::$max_id = $_GET['last_created'] ?? self::$max_id; + self::$max_id = $get['last_created'] ?? self::$max_id; break; case 'uriid': - self::$max_id = $_GET['last_uriid'] ?? self::$max_id; + self::$max_id = $get['last_uriid'] ?? self::$max_id; break; } } @@ -420,26 +426,20 @@ class Network extends BaseModule $items = array_reverse($items); } - $parents_str = ''; if (DBA::isResult($items)) { - $parents_arr = []; - - foreach ($items as $item) { - if (!in_array($item['parent'], $parents_arr) && ($item['parent'] > 0)) { - $parents_arr[] = $item['parent']; - } - } - $parents_str = implode(', ', $parents_arr); + $parents = array_column($items, 'parent'); + } else { + $parents = []; } // We aren't going to try and figure out at the item, group, and page // level which items you've seen and which you haven't. If you're looking // at the top level network page just mark everything seen. - if (!self::$groupId && !self::$forumContactId && self::$selectedTab != 'star') { + if (!self::$groupId && !self::$forumContactId && !self::$star && !self::$mention) { $condition = ['unseen' => true, 'uid' => local_user()]; self::setItemsSeenByCondition($condition); - } elseif ($parents_str) { - $condition = ["`uid` = ? AND `unseen` AND `parent` IN (" . DBA::escape($parents_str) . ")", local_user()]; + } elseif (!empty($parents)) { + $condition = ['unseen' => true, 'uid' => local_user(), 'parent' => $parents]; self::setItemsSeenByCondition($condition); }