pools: fix pool gallery page layout.

Fix the /pools/gallery page layout being broken by 8841de68a.

This required refactoring the PostGalleryComponent to take a set of
PostPreviewComponents instead of a set of Posts.

The upshot is that it's technically possible to have adjustable
thumbnail sizes on the pool gallery page now (although this is not yet
exposed in the UI).
This commit is contained in:
evazion
2021-12-05 01:45:31 -06:00
parent 8841de68ac
commit 2e6f480d07
10 changed files with 58 additions and 54 deletions

View File

@@ -3,13 +3,22 @@ module ComponentsHelper
render PostPreviewComponent.new(post: post, **options)
end
def post_previews_html(posts, **options)
# Render a set of posts as thumbnail gallery.
#
# @param posts [ActiveRecord::Relation<Post>, Array<Post>] A set of posts.
# @param options [Hash] A hash of options for the PostGalleryComponent and PostPreviewComponent.
def render_post_gallery(posts, **options, &block)
posts = posts.includes(:media_asset) if posts.is_a?(ActiveRecord::Relation)
render PostPreviewComponent.with_collection(posts, **options)
end
def render_post_gallery(posts, current_user: CurrentUser.user, **options, &block)
render PostGalleryComponent.new(posts: posts, current_user: current_user, **options), &block
render(PostGalleryComponent.new(**options)) do |gallery|
posts.each do |post|
gallery.post(post: post, size: gallery.size, **options)
end
if block_given?
yield(gallery, posts)
end
end
end
def render_comment(comment, current_user:, **options)