2019-07-02 08:10:25 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class StatusRelationshipsPresenter
|
2020-11-25 21:22:37 +00:00
|
|
|
attr_reader :reblogs_map, :favourites_map
|
2019-07-02 08:10:25 +01:00
|
|
|
|
|
|
|
def initialize(statuses, current_account_id = nil, **options)
|
|
|
|
if current_account_id.nil?
|
2020-11-15 18:48:32 +00:00
|
|
|
@reblogs_map = {}
|
2019-07-02 08:10:25 +01:00
|
|
|
@favourites_map = {}
|
|
|
|
else
|
2020-11-15 18:48:32 +00:00
|
|
|
statuses = statuses.compact
|
|
|
|
status_ids = statuses.flat_map { |s| [s.id, s.reblog_of_id, s.quote_of_id] }.uniq.compact
|
2019-07-02 08:10:25 +01:00
|
|
|
|
2020-11-15 18:48:32 +00:00
|
|
|
@reblogs_map = Status.reblogs_map(status_ids, current_account_id).merge(options[:reblogs_map] || {})
|
2019-07-02 08:10:25 +01:00
|
|
|
@favourites_map = Status.favourites_map(status_ids, current_account_id).merge(options[:favourites_map] || {})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|