From 167740456b1a8372ee7fa14c20d38c634b3441cb Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Thu, 5 Jun 2014 00:59:13 +0200 Subject: [PATCH] Show inline repeats-list in ThreadedNoticeList Also, don't show repeats _as_ separate notices in the list either. --- lib/noticelistitem.php | 2 +- lib/threadednoticelist.php | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/noticelistitem.php b/lib/noticelistitem.php index f46827d1f7..75a1bdaab5 100644 --- a/lib/noticelistitem.php +++ b/lib/noticelistitem.php @@ -70,7 +70,7 @@ class NoticeListItem extends Widget parent::__construct($out); if (!empty($notice->repeat_of)) { $original = Notice::getKV('id', $notice->repeat_of); - if (empty($original)) { // could have been deleted + if (!$original instanceof Notice) { // could have been deleted $this->notice = $notice; } else { $this->notice = $original; diff --git a/lib/threadednoticelist.php b/lib/threadednoticelist.php index ed3193420f..92d9fbc571 100644 --- a/lib/threadednoticelist.php +++ b/lib/threadednoticelist.php @@ -89,7 +89,7 @@ class ThreadedNoticeList extends NoticeList if ($notice->repeat_of) { $orig = Notice::getKV('id', $notice->repeat_of); - if ($orig) { + if ($orig instanceof Notice) { $notice = $orig; } } @@ -102,7 +102,7 @@ class ThreadedNoticeList extends NoticeList // Get the convo's root notice $root = $notice->conversationRoot($this->userProfile); - if ($root) { + if ($root instanceof Notice) { $notice = $root; } @@ -208,6 +208,11 @@ class ThreadedNoticeListItem extends NoticeListItem $moreCutoff = null; while ($notice->fetch()) { if (Event::handle('StartAddNoticeReply', array($this, $this->notice, $notice))) { + // Don't list repeats as separate notices in a conversation + if (!empty($notice->repeat_of)) { + continue; + } + if ($notice->id == $this->notice->id) { // Skip! continue; @@ -316,6 +321,8 @@ class ThreadedNoticeListSubItem extends NoticeListItem { $item = new ThreadedNoticeListInlineFavesItem($this->notice, $this->out); $hasFaves = $item->show(); + $item = new ThreadedNoticeListInlineRepeatsItem($this->notice, $this->out); + $hasRepeats = $item->show(); parent::showEnd(); } } @@ -551,7 +558,7 @@ class ThreadedNoticeListInlineFavesItem extends ThreadedNoticeListFavesItem } /** - * Placeholder for showing faves... + * Placeholder for showing repeats... */ class ThreadedNoticeListRepeatsItem extends NoticeListActorsItem { @@ -612,3 +619,17 @@ class ThreadedNoticeListRepeatsItem extends NoticeListActorsItem $this->out->elementEnd('li'); } } + +// @todo FIXME: needs documentation. +class ThreadedNoticeListInlineRepeatsItem extends ThreadedNoticeListRepeatsItem +{ + function showStart() + { + $this->out->elementStart('div', array('class' => 'entry-content notice-repeats')); + } + + function showEnd() + { + $this->out->elementEnd('div'); + } +} -- 2.39.5