Hook::callAll('register_account', $uid);
Hook::callAll('remove_user', $user);
-### src/Module/Notifications/Ping.php
-
- Hook::callAll('network_ping', $arr);
-
### src/Module/PermissionTooltip.php
Hook::callAll('lockview_content', $item);
Hook::callAll('storage_instance', $data);
Hook::callAll('storage_config', $data);
-### src/Module/Notifications/Ping.php
-
- Hook::callAll('network_ping', $arr);
-
### src/Module/PermissionTooltip.php
Hook::callAll('lockview_content', $item);
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');
$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];
$this->maxId = $maxId;
}
- if (count($selected_items) < $this->itemsPerPage) {
+ if (count($selected_items) < $total) {
$items = $this->getRawChannelItems($request);
}
}
$intro_count = 0;
$mail_count = 0;
$home_count = 0;
- $network_count = 0;
$register_count = 0;
$sysnotify_count = 0;
$circles_unseen = [];
}
$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`"]);
- }
-
- $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++;
- }
- }
+ $home_count = Post::count($condition);
- $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) {
$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;
--- /dev/null
+<?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+');
+ }
+}
'/toggle_mobile' => [Module\ToggleMobile::class, [R::GET]],
'/tos' => [Module\Tos::class, [R::GET]],
+ '/ping_network' => [
+ '[/]' => [Module\Ping\Network::class, [R::GET]],
+ '/archive/{from:\d\d\d\d-\d\d-\d\d}[/{to:\d\d\d\d-\d\d-\d\d}]' => [Module\Ping\Network::class, [R::GET]],
+ '/group/{contact_id:\d+}' => [Module\Ping\Network::class, [R::GET]],
+ '/circle/{circle_id:\d+}' => [Module\Ping\Network::class, [R::GET]],
+ ],
+
'/update_channel[/{content}]' => [Module\Update\Channel::class, [R::GET]],
'/update_community[/{content}]' => [Module\Update\Community::class, [R::GET]],
document.title = originalTitle;
}
- ['net', 'home', 'intro', 'mail', 'events', 'birthdays', 'notification'].forEach(function(type) {
+ ['home', 'intro', 'mail', 'events', 'birthdays', 'notification'].forEach(function(type) {
var number = data[type];
- if (number == 0) {
- number = '';
- $('#' + type + '-update').removeClass('show');
- } else {
- $('#' + type + '-update').addClass('show');
- }
- $('#' + type + '-update').text(number);
+ updateCounter(type, number);
});
var intro = data['intro'];
liveUpdate(src);
}
});
+
+ if (!$('#live-network').length) {
+ var update_url = 'ping_network?ping=1';
+ $.get(update_url, function(net) {
+ updateCounter('net', net);
+ });
+ }
+
if ($('#live-photos').length) {
if (liking) {
liking = 0;
var udargs = ((netargs.length) ? '/' + netargs : '');
- var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&force=' + (force ? 1 : 0) + '&item=' + update_item;
+ var update_url = src + udargs + '&p=' + profile_uid + '&force=' + (force ? 1 : 0) + '&item=' + update_item;
if (force_update) {
force_update = false;
update_url += '&first_uriid=' + match[0].innerHTML;
}
- $.get(update_url, function(data) {
+ $.get('update_' + update_url, function(data) {
in_progress = false;
update_item = 0;
$(window).scrollTop($(window).scrollTop() + $("section").height() - orgHeight);
});
});
+
+ if (src == 'network') {
+ $.get('ping_' + update_url, function(net) {
+ updateCounter('net', net);
+ });
+ }
+}
+
+function updateCounter(type, counter) {
+ if (counter < 0) {
+ return;
+ }
+
+ if (counter == 0) {
+ counter = '';
+ $('#' + type + '-update').removeClass('show');
+ } else {
+ $('#' + type + '-update').addClass('show');
+ }
+ $('#' + type + '-update').text(counter);
}
function updateItem(itemNo) {