From 4f8a3a8c2b098a9b1d60027fbc18adb3867d88a8 Mon Sep 17 00:00:00 2001 From: Parziphal Date: Sun, 7 Sep 2014 16:38:08 -0500 Subject: [PATCH] Fixed #112. --- app/helpers/AvatarHelper.php | 29 +++++++++++++++-------------- app/views/comment/_comment.php | 1 - 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/helpers/AvatarHelper.php b/app/helpers/AvatarHelper.php index 8f5c971..16ff667 100755 --- a/app/helpers/AvatarHelper.php +++ b/app/helpers/AvatarHelper.php @@ -1,6 +1,8 @@ id] = true; $posts_to_send[] = $user->avatar_post; + $this->avatar_posts_registry[] = $user->avatar_post; $img = $this->imageTag($user->avatar_url() . "?" . strtotime($user->avatar_timestamp), array_merge(array('class' => "avatar", 'width' => $user->avatar_width, 'height' => $user->avatar_height), $html_options)); return $this->linkTo($img, array("post#show", 'id' => $user->avatar_post->id), array('class' => "ca" . $user->avatar_post->id, - 'onclick' => "Post.check_avatar_blacklist(".$user->avatar_post->id.", ".$id.")")); + 'onclick' => "return Post.check_avatar_blacklist(".$user->avatar_post->id.", ".$id.")")); #end } public function avatar_init(Post $post = null) { - static $posts = array(); - - if ($post) { - $posts[(string)$post->id] = $post; - } else { - if (!$posts) - return ''; - $ret = ''; - foreach ($posts as $post) - $ret .= 'Post.register('.$post->toJson().")\n"; - $ret .= 'Post.init_blacklisted()'; - return $ret; + if (!$this->avatar_posts_registry) { + return ''; } + + $ret = ''; + foreach ($this->avatar_posts_registry as $post) { + $ret .= 'Post.register('.$post->toJson().");\n"; + } + $ret .= "Post.init_blacklisted();\n"; + + return $ret; } -} \ No newline at end of file +} diff --git a/app/views/comment/_comment.php b/app/views/comment/_comment.php index 303a49a..48a9175 100755 --- a/app/views/comment/_comment.php +++ b/app/views/comment/_comment.php @@ -9,7 +9,6 @@ linkTo($this->t(array('time.x_ago', 't' => $this->timeAgoInWords($this->comment->created_at))), array('post#show', 'id' => $this->comment->post_id, 'anchor' => "c".$this->comment->id)) ?> comment->user and $this->comment->user->has_avatar()) : ?> - avatar_init($this->comment->user->avatar_post) ?>
avatar($this->comment->user, $this->comment->id) ?>