We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 36d56232 authored by Evan Prodromou's avatar Evan Prodromou

a little better notice hiding

parent 10cffa8a
...@@ -192,17 +192,20 @@ class ThreadedNoticeListItem extends NoticeListItem ...@@ -192,17 +192,20 @@ class ThreadedNoticeListItem extends NoticeListItem
$cnt = 0; $cnt = 0;
$moreCutoff = null; $moreCutoff = null;
while ($notice->fetch()) { while ($notice->fetch()) {
if ($notice->id == $this->notice->id) { if (Event::handle('StartAddNoticeReply', array($this, $this->notice, $notice))) {
// Skip! if ($notice->id == $this->notice->id) {
continue; // Skip!
} continue;
$cnt++; }
if ($cnt > $max) { $cnt++;
// boo-yah if ($cnt > $max) {
$moreCutoff = clone($notice); // boo-yah
break; $moreCutoff = clone($notice);
break;
}
$notices[] = clone($notice); // *grumble* inefficient as hell
Event::handle('EndAddNoticeReply', array($this, $this->notice, $notice));
} }
$notices[] = clone($notice); // *grumble* inefficient as hell
} }
if (Event::handle('StartShowThreadedNoticeTail', array($this, $this->notice, &$notices))) { if (Event::handle('StartShowThreadedNoticeTail', array($this, $this->notice, &$notices))) {
...@@ -215,8 +218,9 @@ class ThreadedNoticeListItem extends NoticeListItem ...@@ -215,8 +218,9 @@ class ThreadedNoticeListItem extends NoticeListItem
$hasRepeats = $item->show(); $hasRepeats = $item->show();
if ($notices) { if ($notices) {
if ($moreCutoff) { if ($moreCutoff) {
$item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out); $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out, count($notices));
$item->show(); $item->show();
} }
foreach (array_reverse($notices) as $notice) { foreach (array_reverse($notices) as $notice) {
...@@ -306,6 +310,14 @@ class ThreadedNoticeListSubItem extends NoticeListItem ...@@ -306,6 +310,14 @@ class ThreadedNoticeListSubItem extends NoticeListItem
*/ */
class ThreadedNoticeListMoreItem extends NoticeListItem class ThreadedNoticeListMoreItem extends NoticeListItem
{ {
protected $cnt;
function __construct($notice, $out, $cnt)
{
parent::__construct($notice, $out);
$this->cnt = $cnt;
}
/** /**
* recipe function for displaying a single notice. * recipe function for displaying a single notice.
* *
......
...@@ -348,17 +348,13 @@ class EventPlugin extends MicroappPlugin ...@@ -348,17 +348,13 @@ class EventPlugin extends MicroappPlugin
return true; return true;
} }
function onStartShowThreadedNoticeTail($nli, $notice, &$children) function onStartAddNoticeReply($nli, $parent, $child)
{ {
// Filter out any poll responses // Filter out any poll responses
if ($notice->object_type == Happening::OBJECT_TYPE) { if (($parent->object_type == Happening::OBJECT_TYPE) &&
$children = array_filter($children, array($this, 'isNotRSVP')); in_array($child->object_type, array(RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE))) {
return false;
} }
return true; return true;
} }
function isNotRSVP($notice)
{
return (!in_array($notice->object_type, array(RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE)));
}
} }
...@@ -481,17 +481,13 @@ class PollPlugin extends MicroAppPlugin ...@@ -481,17 +481,13 @@ class PollPlugin extends MicroAppPlugin
return _m('APPTITLE','Poll'); return _m('APPTITLE','Poll');
} }
function onStartShowThreadedNoticeTail($nli, $notice, &$children) function onStartAddNoticeReply($nli, $parent, $child)
{ {
// Filter out any poll responses // Filter out any poll responses
if ($notice->object_type == self::POLL_OBJECT) { if ($parent->object_type == self::POLL_OBJECT &&
$children = array_filter($children, array($this, 'isNotPollResponse')); $child->object_type == self::POLL_RESPONSE_OBJECT) {
return false;
} }
return true; return true;
} }
function isNotPollResponse($notice)
{
return ($notice->object_type != self::POLL_RESPONSE_OBJECT);
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment