]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
a little better notice hiding
authorEvan Prodromou <evan@status.net>
Thu, 21 Apr 2011 17:37:05 +0000 (13:37 -0400)
committerEvan Prodromou <evan@status.net>
Thu, 21 Apr 2011 17:37:05 +0000 (13:37 -0400)
lib/threadednoticelist.php
plugins/Event/EventPlugin.php
plugins/Poll/PollPlugin.php

index 96be0df0c58d037eb2eb988665c077b84a0739f4..221cf33aae5254431fb307707137ad033679bda7 100644 (file)
@@ -192,17 +192,20 @@ class ThreadedNoticeListItem extends NoticeListItem
             $cnt = 0;
             $moreCutoff = null;
             while ($notice->fetch()) {
-                if ($notice->id == $this->notice->id) {
-                    // Skip!
-                    continue;
-                }
-                $cnt++;
-                if ($cnt > $max) {
-                    // boo-yah
-                    $moreCutoff = clone($notice);
-                    break;
+                if (Event::handle('StartAddNoticeReply', array($this, $this->notice, $notice))) {
+                    if ($notice->id == $this->notice->id) {
+                        // Skip!
+                        continue;
+                    }
+                    $cnt++;
+                    if ($cnt > $max) {
+                        // boo-yah
+                        $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))) {
@@ -215,8 +218,9 @@ class ThreadedNoticeListItem extends NoticeListItem
                 $hasRepeats = $item->show();
 
                 if ($notices) {
+
                     if ($moreCutoff) {
-                        $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out);
+                        $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out, count($notices));
                         $item->show();
                     }
                     foreach (array_reverse($notices) as $notice) {
@@ -306,6 +310,14 @@ class ThreadedNoticeListSubItem 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.
      *
index a9644e7a2ccc12b00ab36569625fbf80226387d3..dfbcfd8dc669d13830a450dd2dbbe5cb55440446 100644 (file)
@@ -348,17 +348,13 @@ class EventPlugin extends MicroappPlugin
         return true;
     }
 
-    function onStartShowThreadedNoticeTail($nli, $notice, &$children)
+    function onStartAddNoticeReply($nli, $parent, $child)
     {
         // Filter out any poll responses
-        if ($notice->object_type == Happening::OBJECT_TYPE) {
-            $children = array_filter($children, array($this, 'isNotRSVP'));
+        if (($parent->object_type == Happening::OBJECT_TYPE) &&
+            in_array($child->object_type, array(RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE))) {
+            return false;
         }
         return true;
     }
-
-    function isNotRSVP($notice)
-    {
-        return (!in_array($notice->object_type, array(RSVP::POSITIVE, RSVP::NEGATIVE, RSVP::POSSIBLE)));
-    }
 }
index f9b5808b1cb20779a287ee49a2ee022b1c67c5ee..5a7d5c22fddd1b660b9fed2ac3233535c802f7a6 100644 (file)
@@ -481,17 +481,13 @@ class PollPlugin extends MicroAppPlugin
         return _m('APPTITLE','Poll');
     }
 
-    function onStartShowThreadedNoticeTail($nli, $notice, &$children)
+    function onStartAddNoticeReply($nli, $parent, $child)
     {
         // Filter out any poll responses
-        if ($notice->object_type == self::POLL_OBJECT) {
-            $children = array_filter($children, array($this, 'isNotPollResponse'));
+        if ($parent->object_type == self::POLL_OBJECT &&
+            $child->object_type == self::POLL_RESPONSE_OBJECT) {
+            return false;
         }
         return true;
     }
-
-    function isNotPollResponse($notice)
-    {
-        return ($notice->object_type != self::POLL_RESPONSE_OBJECT);
-    }
 }