parent
335b1c32aa
commit
6e74ee7d21
3 changed files with 4 additions and 7 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
* Refactor HomeController#toggle\_mobile [#6260](https://github.com/diaspora/diaspora/pull/6260)
|
* Refactor HomeController#toggle\_mobile [#6260](https://github.com/diaspora/diaspora/pull/6260)
|
||||||
* Extract CommentService from CommentsController [#6307](https://github.com/diaspora/diaspora/pull/6307)
|
* Extract CommentService from CommentsController [#6307](https://github.com/diaspora/diaspora/pull/6307)
|
||||||
* Extract user/profile discovery into the diaspora\_federation-rails gem [#6310](https://github.com/diaspora/diaspora/pull/6310)
|
* Extract user/profile discovery into the diaspora\_federation-rails gem [#6310](https://github.com/diaspora/diaspora/pull/6310)
|
||||||
|
* Refactor PostPresenter [#6315](https://github.com/diaspora/diaspora/pull/6315)
|
||||||
|
|
||||||
## Bug fixes
|
## Bug fixes
|
||||||
* Fix indentation and a link title on the default home page [#6212](https://github.com/diaspora/diaspora/pull/6212)
|
* Fix indentation and a link title on the default home page [#6212](https://github.com/diaspora/diaspora/pull/6212)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class PostInteractionPresenter
|
||||||
def as_json(_options={})
|
def as_json(_options={})
|
||||||
{
|
{
|
||||||
likes: as_api(@post.likes),
|
likes: as_api(@post.likes),
|
||||||
reshares: PostPresenter.collection_json(@post.reshares, @current_user),
|
reshares: PostPresenter.as_collection(@post.reshares, :as_json, @current_user),
|
||||||
comments: CommentPresenter.as_collection(@post.comments.order("created_at ASC")),
|
comments: CommentPresenter.as_collection(@post.comments.order("created_at ASC")),
|
||||||
participations: as_api(participations),
|
participations: as_api(participations),
|
||||||
comments_count: @post.comments_count,
|
comments_count: @post.comments_count,
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,13 @@
|
||||||
class PostPresenter
|
class PostPresenter < BasePresenter
|
||||||
include PostsHelper
|
include PostsHelper
|
||||||
|
|
||||||
attr_accessor :post, :current_user
|
attr_accessor :post
|
||||||
|
|
||||||
def initialize(post, current_user=nil)
|
def initialize(post, current_user=nil)
|
||||||
@post = post
|
@post = post
|
||||||
@current_user = current_user
|
@current_user = current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.collection_json(collection, current_user)
|
|
||||||
collection.map {|post| PostPresenter.new(post, current_user) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def as_json(_options={})
|
def as_json(_options={})
|
||||||
@post.include_root_in_json = false
|
@post.include_root_in_json = false
|
||||||
@post.as_json(only: directly_retrieved_attributes).merge(non_directly_retrieved_attributes)
|
@post.as_json(only: directly_retrieved_attributes).merge(non_directly_retrieved_attributes)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue