about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authornullkal <nullkal@nil.nu>2017-08-26 01:50:52 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-08-25 18:50:52 +0200
commitc2af1381130caae0acc02db853580a2bdab61078 (patch)
tree5129ff07cb41f5a132b5e7da56f7686f9c2c0776 /app
parentfb8aa2b3bac122f819b07c7f9461b26cc369c621 (diff)
Allow multiple pinned statuses to be shown and make them be ordered b… (#4690)
* Allow multiple pinned statuses to be shown and make them be ordered by pinned date

* Set timestamps NOT NULL

* Make single-line pinned_statuses

* Spec for pinned_statuses

* Remove redundant empty line
Diffstat (limited to 'app')
-rw-r--r--app/controllers/accounts_controller.rb2
-rw-r--r--app/models/account.rb2
-rw-r--r--app/models/status_pin.rb2
3 files changed, 4 insertions, 2 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index f4ca239ba..8dad12f11 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -14,7 +14,7 @@ class AccountsController < ApplicationController
           return
         end
 
-        @pinned_statuses = cache_collection(@account.pinned_statuses.limit(1), Status) unless media_requested?
+        @pinned_statuses = cache_collection(@account.pinned_statuses, Status) unless media_requested?
         @statuses        = filtered_statuses.paginate_by_max_id(20, params[:max_id], params[:since_id])
         @statuses        = cache_collection(@statuses, Status)
         @next_url        = next_url unless @statuses.empty?
diff --git a/app/models/account.rb b/app/models/account.rb
index b83aa1159..529334559 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -79,7 +79,7 @@ class Account < ApplicationRecord
 
   # Pinned statuses
   has_many :status_pins, inverse_of: :account, dependent: :destroy
-  has_many :pinned_statuses, through: :status_pins, class_name: 'Status', source: :status
+  has_many :pinned_statuses, -> { reorder('status_pins.created_at DESC') }, through: :status_pins, class_name: 'Status', source: :status
 
   # Media
   has_many :media_attachments, dependent: :destroy
diff --git a/app/models/status_pin.rb b/app/models/status_pin.rb
index c9a669344..a72c19750 100644
--- a/app/models/status_pin.rb
+++ b/app/models/status_pin.rb
@@ -6,6 +6,8 @@
 #  id         :integer          not null, primary key
 #  account_id :integer          not null
 #  status_id  :integer          not null
+#  created_at :datetime         not null
+#  updated_at :datetime         not null
 #
 
 class StatusPin < ApplicationRecord