From 58d798b6079d1c61cee4a4013d234ef224687052 Mon Sep 17 00:00:00 2001
From: Evan Prodromou <evan@status.net>
Date: Tue, 2 Aug 2011 12:01:41 -0400
Subject: [PATCH] Change NoticeList::prefill() to a static function

---
 lib/noticelist.php         | 19 ++++++++++++++++---
 lib/threadednoticelist.php | 12 ++----------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/lib/noticelist.php b/lib/noticelist.php
index aaa3b3c986..a4781d9daa 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -87,7 +87,7 @@ class NoticeList extends Widget
 		$total   = count($notices);
 		$notices = array_slice($notices, 0, NOTICES_PER_PAGE);
 		
-    	$this->prefill($notices);
+    	self::prefill($notices);
     	
     	foreach ($notices as $notice) {
 
@@ -122,10 +122,23 @@ class NoticeList extends Widget
         return new NoticeListItem($notice, $this->out);
     }
     
-    function prefill(&$notices)
+    static function prefill(&$notices, $avatarSize=AVATAR_STREAM_SIZE)
     {
     	// Prefill the profiles
     	$profiles = Notice::fillProfiles($notices);
-    	Profile::fillAvatars($profiles, AVATAR_STREAM_SIZE);
+    	// Prefill the avatars
+    	Profile::fillAvatars($profiles, $avatarSize);
+    	
+    	$p = Profile::current();
+    	
+    	$ids = array();
+    	
+    	foreach ($notices as $notice) {
+    	    $ids[] = $notice->id;
+    	}
+    	
+    	if (!empty($p)) {
+    		Memcached_DataObject::pivotGet('Fave', 'notice_id', $ids, array('user_id' => $p->id));
+    	}
     }
 }
diff --git a/lib/threadednoticelist.php b/lib/threadednoticelist.php
index a63d25110f..407f7bdde3 100644
--- a/lib/threadednoticelist.php
+++ b/lib/threadednoticelist.php
@@ -80,7 +80,7 @@ class ThreadedNoticeList extends NoticeList
 		$total = count($notices);
 		$notices = array_slice($notices, 0, NOTICES_PER_PAGE);
 		
-    	$this->prefill($notices);
+    	self::prefill($notices);
     	
         $conversations = array();
         
@@ -224,8 +224,7 @@ class ThreadedNoticeListItem extends NoticeListItem
                         $item = new ThreadedNoticeListMoreItem($moreCutoff, $this->out, count($notices));
                         $item->show();
                     }
-                    // XXX: replicating NoticeList::prefill(), annoyingly
-                    $this->prefill($notices);
+                    NoticeList::prefill($notices, AVATAR_MINI_SIZE);
                     foreach (array_reverse($notices) as $notice) {
                         if (Event::handle('StartShowThreadedNoticeSub', array($this, $this->notice, $notice))) {
                             $item = new ThreadedNoticeListSubItem($notice, $this->notice, $this->out);
@@ -250,13 +249,6 @@ class ThreadedNoticeListItem extends NoticeListItem
 
         parent::showEnd();
     }
-    
-    function prefill(&$notices)
-    {       
-    	// Prefill the profiles
-    	$profiles = Notice::fillProfiles($notices);
-    	Profile::fillAvatars($profiles, AVATAR_MINI_SIZE);
-    }
 }
 
 // @todo FIXME: needs documentation.
-- 
2.39.5