diff --git a/app/models/concerns/account/associations.rb b/app/models/concerns/account/associations.rb index 1c67b07e511..064486a4859 100644 --- a/app/models/concerns/account/associations.rb +++ b/app/models/concerns/account/associations.rb @@ -26,7 +26,7 @@ module Account::Associations # Pinned statuses has_many :status_pins, inverse_of: :account, dependent: :destroy - has_many :pinned_statuses, -> { reorder('status_pins.created_at DESC') }, through: :status_pins, class_name: 'Status', source: :status + has_many :pinned_statuses, -> { StatusPin.latest }, through: :status_pins, class_name: 'Status', source: :status # Endorsements has_many :account_pins, inverse_of: :account, dependent: :destroy diff --git a/app/models/status_pin.rb b/app/models/status_pin.rb index dae4a5b4e6b..3ddbc2023a1 100644 --- a/app/models/status_pin.rb +++ b/app/models/status_pin.rb @@ -17,6 +17,8 @@ class StatusPin < ApplicationRecord validates_with StatusPinValidator + scope :latest, -> { reorder(created_at: :desc) } + after_destroy :invalidate_cleanup_info def invalidate_cleanup_info