mirror of
https://github.com/friendica/friendica
synced 2025-04-25 14:30:10 +00:00
Issue 13910: Display the unseen counter based on the channel
This commit is contained in:
parent
0ccb3e7efe
commit
618a3153ab
7 changed files with 107 additions and 47 deletions
|
@ -235,6 +235,7 @@ class Timeline extends BaseModule
|
|||
protected function getChannelItems(array $request)
|
||||
{
|
||||
$items = $this->getRawChannelItems($request);
|
||||
$total = min(count($items), $this->itemsPerPage);
|
||||
|
||||
$contacts = $this->database->selectToArray('user-contact', ['cid'], ['channel-frequency' => Contact\User::FREQUENCY_REDUCED, 'cid' => array_column($items, 'owner-id')]);
|
||||
$reduced = array_column($contacts, 'cid');
|
||||
|
@ -246,8 +247,8 @@ class Timeline extends BaseModule
|
|||
$owner_posts = [];
|
||||
$selected_items = [];
|
||||
|
||||
while (count($selected_items) < $this->itemsPerPage && ++$count < 50 && count($items) > 0) {
|
||||
$maxposts = round((count($items) / $this->itemsPerPage) * $maxpostperauthor);
|
||||
while (count($selected_items) < $total && ++$count < 50 && count($items) > 0) {
|
||||
$maxposts = round((count($items) / $total) * $maxpostperauthor);
|
||||
$minId = $items[array_key_first($items)][$this->order];
|
||||
$maxId = $items[array_key_last($items)][$this->order];
|
||||
|
||||
|
@ -279,7 +280,7 @@ class Timeline extends BaseModule
|
|||
$this->maxId = $maxId;
|
||||
}
|
||||
|
||||
if (count($selected_items) < $this->itemsPerPage) {
|
||||
if (count($selected_items) < $total) {
|
||||
$items = $this->getRawChannelItems($request);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,6 @@ class Ping extends BaseModule
|
|||
$intro_count = 0;
|
||||
$mail_count = 0;
|
||||
$home_count = 0;
|
||||
$network_count = 0;
|
||||
$register_count = 0;
|
||||
$sysnotify_count = 0;
|
||||
$circles_unseen = [];
|
||||
|
@ -125,34 +124,13 @@ class Ping extends BaseModule
|
|||
}
|
||||
|
||||
$condition = [
|
||||
"`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
|
||||
"`unseen` AND `uid` = ? AND NOT `origin` AND `wall` AND (`vid` != ? OR `vid` IS NULL)",
|
||||
$this->session->getLocalUserId(), Verb::getID(Activity::FOLLOW)
|
||||
];
|
||||
|
||||
// No point showing counts for non-top-level posts when the network page is ordered by received field
|
||||
if (Network::getTimelineOrderBySession($this->session, $this->pconfig) == 'received') {
|
||||
$condition = DBA::mergeConditions($condition, ["`parent` = `id`"]);
|
||||
}
|
||||
$home_count = Post::count($condition);
|
||||
|
||||
$items_unseen = $this->database->toArray(Post::selectForUser(
|
||||
$this->session->getLocalUserId(),
|
||||
['wall', 'uid', 'uri-id'],
|
||||
$condition,
|
||||
['limit' => 1000],
|
||||
));
|
||||
$arr = ['items' => $items_unseen];
|
||||
Hook::callAll('network_ping', $arr);
|
||||
|
||||
foreach ($items_unseen as $item) {
|
||||
if ($item['wall']) {
|
||||
$home_count++;
|
||||
} else {
|
||||
$network_count++;
|
||||
}
|
||||
}
|
||||
|
||||
$compute_circle_counts = $this->config->get('system','compute_circle_counts');
|
||||
if ($network_count && $compute_circle_counts) {
|
||||
if ($this->config->get('system','compute_circle_counts')) {
|
||||
// Find out how unseen network posts are spread across circles
|
||||
foreach (Circle::countUnseen($this->session->getLocalUserId()) as $circle_count) {
|
||||
if ($circle_count['count'] > 0) {
|
||||
|
@ -281,7 +259,6 @@ class Ping extends BaseModule
|
|||
$data = [];
|
||||
$data['intro'] = $intro_count;
|
||||
$data['mail'] = $mail_count;
|
||||
$data['net'] = ($network_count < 1000) ? $network_count : '999+';
|
||||
$data['home'] = ($home_count < 1000) ? $home_count : '999+';
|
||||
$data['register'] = $register_count;
|
||||
|
||||
|
|
61
src/Module/Ping/Network.php
Normal file
61
src/Module/Ping/Network.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2024, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Ping;
|
||||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Module\Conversation\Network as NetworkModule;
|
||||
|
||||
class Network extends NetworkModule
|
||||
{
|
||||
protected function rawContent(array $request = [])
|
||||
{
|
||||
if (!empty($request['ping'])) {
|
||||
$request = $this->session->get('network-request');
|
||||
}
|
||||
|
||||
if (!isset($request['p']) || !isset($request['item'])) {
|
||||
System::exit();
|
||||
}
|
||||
|
||||
$this->parseRequest($request);
|
||||
|
||||
if ($this->force || !is_null($this->maxId)) {
|
||||
System::httpExit('');
|
||||
}
|
||||
|
||||
if (empty($request['ping'])) {
|
||||
$this->session->set('network-request', $request);
|
||||
}
|
||||
|
||||
$this->itemsPerPage = 100;
|
||||
|
||||
if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) {
|
||||
$items = $this->getChannelItems($request);
|
||||
} elseif ($this->community->isTimeline($this->selectedTab)) {
|
||||
$items = $this->getCommunityItems();
|
||||
} else {
|
||||
$items = $this->getItems();
|
||||
}
|
||||
$count = count($items);
|
||||
System::httpExit(($count < 100) ? $count : '99+');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue