Cut repeats out of the magic handling

This commit is contained in:
Brion Vibber 2011-02-28 17:23:01 -08:00
parent 407cc851cc
commit 082ddf365e

View File

@ -157,35 +157,37 @@ class ThreadedNoticeListItem extends NoticeListItem
function showEnd() function showEnd()
{ {
$notice = Notice::conversationStream($this->notice->conversation, 0, self::INITIAL_ITEMS + 2); if (!$this->repeat) {
$notices = array(); $notice = Notice::conversationStream($this->notice->conversation, 0, self::INITIAL_ITEMS + 2);
$cnt = 0; $notices = array();
$moreCutoff = null; $cnt = 0;
while ($notice->fetch()) { $moreCutoff = null;
if ($notice->id == $this->notice->id) { while ($notice->fetch()) {
// Skip! if ($notice->id == $this->notice->id) {
continue; // Skip!
continue;
}
$cnt++;
if ($cnt > self::INITIAL_ITEMS) {
// boo-yah
$moreCutoff = clone($notice);
break;
}
$notices[] = clone($notice); // *grumble* inefficient as hell
} }
$cnt++;
if ($cnt > self::INITIAL_ITEMS) {
// boo-yah
$moreCutoff = clone($notice);
break;
}
$notices[] = clone($notice); // *grumble* inefficient as hell
}
if ($notices) { if ($notices) {
$this->out->elementStart('ul', 'notices threaded-notices xoxo'); $this->out->elementStart('ul', 'notices threaded-notices xoxo');
if ($moreCutoff) { if ($moreCutoff) {
$item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out); $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out);
$item->show(); $item->show();
}
foreach (array_reverse($notices) as $notice) {
$item = new ThreadedNoticeListSubItem($notice, $this->out);
$item->show();
}
$this->out->elementEnd('ul');
} }
foreach (array_reverse($notices) as $notice) {
$item = new ThreadedNoticeListSubItem($notice, $this->out);
$item->show();
}
$this->out->elementEnd('ul');
} }
parent::showEnd(); parent::showEnd();