Separate media_attachments property
This commit is contained in:
parent
51e8eddbb4
commit
0b9151859d
3 changed files with 18 additions and 5 deletions
|
@ -66,8 +66,12 @@ export function normalizeStatus(status, normalOldStatus) {
|
||||||
normalStatus.filtered = status.filtered.map(normalizeFilterResult);
|
normalStatus.filtered = status.filtered.map(normalizeFilterResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.emoji_reactions && normalOldStatus && normalOldStatus.get('emoji_reactions')) {
|
if (status.emoji_reactions) {
|
||||||
normalStatus.emoji_reactions = normalizeEmojiReactions(normalOldStatus.get('emoji_reactions').toArray());
|
normalStatus.emoji_reactions = normalizeEmojiReactions(status.emoji_reactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status.media_attachments_ex) {
|
||||||
|
normalStatus.media_attachments = status.media_attachments.concat(status.media_attachments_ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only calculate these values when status first encountered and
|
// Only calculate these values when status first encountered and
|
||||||
|
@ -104,8 +108,8 @@ export function normalizeEmojiReactions(emoji_reactions) {
|
||||||
const myAccountId = me;
|
const myAccountId = me;
|
||||||
let converted = [];
|
let converted = [];
|
||||||
for (let emoji_reaction of emoji_reactions) {
|
for (let emoji_reaction of emoji_reactions) {
|
||||||
let obj = emoji_reaction.toObject();
|
let obj = emoji_reaction;
|
||||||
obj.me = obj.account_ids.toArray().some((id) => id === myAccountId);
|
obj.me = obj.account_ids.some((id) => id === myAccountId);
|
||||||
converted.push(obj);
|
converted.push(obj);
|
||||||
}
|
}
|
||||||
return converted;
|
return converted;
|
||||||
|
|
|
@ -293,6 +293,14 @@ class Status < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ordered_media_attachments_original_mastodon
|
||||||
|
ordered_media_attachments.take(4)
|
||||||
|
end
|
||||||
|
|
||||||
|
def ordered_media_attachments_extra
|
||||||
|
ordered_media_attachments.drop(4).take(4)
|
||||||
|
end
|
||||||
|
|
||||||
def replies_count
|
def replies_count
|
||||||
status_stat&.replies_count || 0
|
status_stat&.replies_count || 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,7 +22,8 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||||
belongs_to :application, if: :show_application?
|
belongs_to :application, if: :show_application?
|
||||||
belongs_to :account, serializer: REST::AccountSerializer
|
belongs_to :account, serializer: REST::AccountSerializer
|
||||||
|
|
||||||
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
has_many :ordered_media_attachments_original_mastodon, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||||
|
has_many :ordered_media_attachments_extra, key: :media_attachments_ex, serializer: REST::MediaAttachmentSerializer
|
||||||
has_many :ordered_mentions, key: :mentions
|
has_many :ordered_mentions, key: :mentions
|
||||||
has_many :tags
|
has_many :tags
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue