Move direct serializer usage out of admin view partial (#29028)

This commit is contained in:
Matt Jankowski 2024-02-06 08:18:37 -05:00 committed by GitHub
parent 2d6ab44556
commit 69e61fff38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View file

@ -15,9 +15,20 @@ module ReactComponentHelper
div_tag_with_data(data)
end
def serialized_media_attachments(media_attachments)
media_attachments.map { |attachment| serialized_attachment(attachment) }
end
private
def div_tag_with_data(data)
content_tag(:div, nil, data: data)
end
def serialized_attachment(attachment)
ActiveModelSerializers::SerializableResource.new(
attachment,
serializer: REST::MediaAttachmentSerializer
).as_json
end
end

View file

@ -12,6 +12,6 @@
= react_component :media_gallery,
height: 343,
lang: status.language,
media: status.ordered_media_attachments.map { |a| ActiveModelSerializers::SerializableResource.new(a, serializer: REST::MediaAttachmentSerializer).as_json },
media: serialized_media_attachments(status.ordered_media_attachments),
sensitive: status.sensitive?,
visible: false