Merge pull request #11569 from annando/issue-11431

Issue 11431: Only show pinned posts on contacts and your own ones
This commit is contained in:
Hypolite Petovan 2022-05-28 18:24:37 -04:00 committed by GitHub
commit a503d5ac1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -443,7 +443,7 @@ class Conversation
$previewing = (($preview) ? ' preview ' : ''); $previewing = (($preview) ? ' preview ' : '');
if ($mode === 'network') { if ($mode === 'network') {
$items = $this->addChildren($items, false, $order, $uid); $items = $this->addChildren($items, false, $order, $uid, $mode);
if (!$update) { if (!$update) {
/* /*
* The special div is needed for liveUpdate to kick in for this page. * The special div is needed for liveUpdate to kick in for this page.
@ -469,7 +469,7 @@ class Conversation
. "'; </script>\r\n"; . "'; </script>\r\n";
} }
} elseif ($mode === 'profile') { } elseif ($mode === 'profile') {
$items = $this->addChildren($items, false, $order, $uid); $items = $this->addChildren($items, false, $order, $uid, $mode);
if (!$update) { if (!$update) {
$tab = !empty($_GET['tab']) ? trim($_GET['tab']) : 'posts'; $tab = !empty($_GET['tab']) ? trim($_GET['tab']) : 'posts';
@ -486,7 +486,7 @@ class Conversation
} }
} }
} elseif ($mode === 'notes') { } elseif ($mode === 'notes') {
$items = $this->addChildren($items, false, $order, local_user()); $items = $this->addChildren($items, false, $order, local_user(), $mode);
if (!$update) { if (!$update) {
$live_update_div = '<div id="live-notes"></div>' . "\r\n" $live_update_div = '<div id="live-notes"></div>' . "\r\n"
@ -494,7 +494,7 @@ class Conversation
. "; var netargs = '/?f='; </script>\r\n"; . "; var netargs = '/?f='; </script>\r\n";
} }
} elseif ($mode === 'display') { } elseif ($mode === 'display') {
$items = $this->addChildren($items, false, $order, $uid); $items = $this->addChildren($items, false, $order, $uid, $mode);
if (!$update) { if (!$update) {
$live_update_div = '<div id="live-display"></div>' . "\r\n" $live_update_div = '<div id="live-display"></div>' . "\r\n"
@ -502,7 +502,7 @@ class Conversation
. "</script>"; . "</script>";
} }
} elseif ($mode === 'community') { } elseif ($mode === 'community') {
$items = $this->addChildren($items, true, $order, $uid); $items = $this->addChildren($items, true, $order, $uid, $mode);
if (!$update) { if (!$update) {
$live_update_div = '<div id="live-community"></div>' . "\r\n" $live_update_div = '<div id="live-community"></div>' . "\r\n"
@ -512,7 +512,7 @@ class Conversation
. "'; </script>\r\n"; . "'; </script>\r\n";
} }
} elseif ($mode === 'contacts') { } elseif ($mode === 'contacts') {
$items = $this->addChildren($items, false, $order, $uid); $items = $this->addChildren($items, false, $order, $uid, $mode);
if (!$update) { if (!$update) {
$live_update_div = '<div id="live-contact"></div>' . "\r\n" $live_update_div = '<div id="live-contact"></div>' . "\r\n"
@ -904,15 +904,15 @@ class Conversation
* The system will fetch the comments for the local user whenever possible. * The system will fetch the comments for the local user whenever possible.
* This behaviour is currently needed to allow commenting on Friendica posts. * This behaviour is currently needed to allow commenting on Friendica posts.
* *
* @param array $parents Parent items * @param array $parents Parent items
* * @param bool $block_authors
* @param $block_authors * @param bool $order
* @param $order * @param int $uid
* @param $uid * @param string $mode
* @return array items with parents and comments * @return array items with parents and comments
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private function addChildren(array $parents, $block_authors, $order, $uid) private function addChildren(array $parents, bool $block_authors, string $order, int $uid, string $mode)
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
if (count($parents) > 1) { if (count($parents) > 1) {
@ -974,6 +974,10 @@ class Conversation
continue; continue;
} }
if (($mode != 'contacts') && !$row['origin']) {
$row['featured'] = false;
}
if ($max_comments > 0) { if ($max_comments > 0) {
if (($row['gravity'] == GRAVITY_COMMENT) && (++$commentcounter[$row['parent-uri-id']] > $max_comments)) { if (($row['gravity'] == GRAVITY_COMMENT) && (++$commentcounter[$row['parent-uri-id']] > $max_comments)) {
continue; continue;