about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/accounts_controller.rb4
-rw-r--r--app/controllers/stream_entries_controller.rb14
2 files changed, 16 insertions, 2 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index c10a2c680..2d4c2dd9a 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -11,8 +11,8 @@ class AccountsController < ApplicationController
 
         if user_signed_in?
           status_ids  = @statuses.collect { |s| [s.id, s.reblog_of_id] }.flatten.uniq
-          @favourited = Favourite.where(status_id: status_ids).where(account_id: current_user.account_id).map { |f| [f.status_id, true] }.to_h
-          @reblogged  = Status.where(reblog_of_id: status_ids).where(account_id: current_user.account_id).map { |s| [s.reblog_of_id, true] }.to_h
+          @favourited = Status.favourites_map(status_ids, current_user.account_id)
+          @reblogged  = Status.reblogs_map(status_ids, current_user.account_id)
         else
           @favourited = {}
           @reblogged  = {}
diff --git a/app/controllers/stream_entries_controller.rb b/app/controllers/stream_entries_controller.rb
index 1e50d3b60..c26149627 100644
--- a/app/controllers/stream_entries_controller.rb
+++ b/app/controllers/stream_entries_controller.rb
@@ -7,6 +7,20 @@ class StreamEntriesController < ApplicationController
   def show
     @type = @stream_entry.activity_type.downcase
 
+    if @stream_entry.activity_type == 'Status'
+      @ancestors   = @stream_entry.activity.ancestors.with_includes.with_counters
+      @descendants = @stream_entry.activity.descendants.with_includes.with_counters
+
+      if user_signed_in?
+        status_ids  = [@stream_entry.activity_id] + @ancestors.map { |s| s.id } + @descendants.map { |s| s.id }
+        @favourited = Status.favourites_map(status_ids, current_user.account_id)
+        @reblogged  = Status.reblogs_map(status_ids, current_user.account_id)
+      else
+        @favourited = {}
+        @reblogged  = {}
+      end
+    end
+
     respond_to do |format|
       format.html
       format.atom