diff options
Diffstat (limited to 'app/controllers/api/v1/timelines/home_controller.rb')
-rw-r--r-- | app/controllers/api/v1/timelines/home_controller.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/api/v1/timelines/home_controller.rb b/app/controllers/api/v1/timelines/home_controller.rb index fcd0757f1..3e8de92bb 100644 --- a/app/controllers/api/v1/timelines/home_controller.rb +++ b/app/controllers/api/v1/timelines/home_controller.rb @@ -27,7 +27,9 @@ class Api::V1::Timelines::HomeController < Api::BaseController end def home_statuses - account_home_feed.get( + home_feed = account_home_feed + preload_media(home_feed.get(DEFAULT_STATUSES_LIMIT * 2, params[:max_id], params[:since_id], params[:min_id])) + home_feed.get( limit_param(DEFAULT_STATUSES_LIMIT), params[:max_id], params[:since_id], @@ -66,4 +68,9 @@ class Api::V1::Timelines::HomeController < Api::BaseController def regeneration_in_progress? Redis.current.exists("account:#{current_account.id}:regeneration") end + + def preload_media(statuses) + fetch_ids = statuses.flat_map { |s| s.media_attachments.select { |m| m.needs_redownload? }.pluck(:id) }.uniq + fetch_ids.each { |m| FetchMediaWorker.perform_async(m) } + end end |