forked from treehouse/mastodon
parent
f1ed855f96
commit
f31e58af9e
|
@ -74,8 +74,17 @@ module StatusThreadingConcern
|
||||||
statuses = statuses_with_accounts(ids).to_a
|
statuses = statuses_with_accounts(ids).to_a
|
||||||
account_ids = statuses.map(&:account_id).uniq
|
account_ids = statuses.map(&:account_id).uniq
|
||||||
domains = statuses.map(&:account_domain).compact.uniq
|
domains = statuses.map(&:account_domain).compact.uniq
|
||||||
|
relations = relations_map_for_account(account, account_ids, domains)
|
||||||
|
|
||||||
|
statuses.reject! { |status| filter_from_context?(status, account, relations) }
|
||||||
|
|
||||||
|
# Order ancestors/descendants by tree path
|
||||||
|
statuses.sort_by! { |status| ids.index(status.id) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def relations_map_for_account(account, account_ids, domains)
|
||||||
|
return {} if account.nil?
|
||||||
|
|
||||||
relations = if account.present?
|
|
||||||
{
|
{
|
||||||
blocking: Account.blocking_map(account_ids, account.id),
|
blocking: Account.blocking_map(account_ids, account.id),
|
||||||
blocked_by: Account.blocked_by_map(account_ids, account.id),
|
blocked_by: Account.blocked_by_map(account_ids, account.id),
|
||||||
|
@ -85,12 +94,6 @@ module StatusThreadingConcern
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
statuses.reject! { |status| filter_from_context?(status, account, relations) }
|
|
||||||
|
|
||||||
# Order ancestors/descendants by tree path
|
|
||||||
statuses.sort_by! { |status| ids.index(status.id) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def statuses_with_accounts(ids)
|
def statuses_with_accounts(ids)
|
||||||
Status.where(id: ids).includes(:account)
|
Status.where(id: ids).includes(:account)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue