Merge pull request #382 from kmycode/upstream-20231225

Upstream 20231225
This commit is contained in:
KMY(雪あすか) 2023-12-25 10:33:53 +09:00 committed by GitHub
commit 2805447b98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
151 changed files with 1711 additions and 644 deletions

View file

@ -83,7 +83,7 @@ class Status < ApplicationRecord
has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread, dependent: nil
has_many :mentions, dependent: :destroy, inverse_of: :status
has_many :mentioned_accounts, through: :mentions, source: :account, class_name: 'Account'
has_many :media_attachments, -> { order('id asc') }, dependent: :nullify, inverse_of: false
has_many :media_attachments, dependent: :nullify, inverse_of: false
has_many :reference_objects, class_name: 'StatusReference', inverse_of: :status, dependent: :destroy
has_many :references, through: :reference_objects, class_name: 'Status', source: :target_status
has_many :referenced_by_status_objects, foreign_key: 'target_status_id', class_name: 'StatusReference', inverse_of: :target_status, dependent: :destroy
@ -347,7 +347,9 @@ class Status < ApplicationRecord
def ordered_media_attachments
if ordered_media_attachment_ids.nil?
media_attachments
# NOTE: sort Ruby-side to avoid hitting the database when the status is
# not persisted to database yet
media_attachments.sort_by(&:id)
else
map = media_attachments.index_by(&:id)
ordered_media_attachment_ids.filter_map { |media_attachment_id| map[media_attachment_id] }