Added GroupPinnedStatuses
• Added: - GroupPinnedStatuses - controllers for timeline, creation, deletion - redux actions, reducers for creation, deletion - timeline fetching in timelines action - options to pin, unpin in status options popover for group admin
This commit is contained in:
@@ -17,6 +17,10 @@ module GroupInteractions
|
||||
follow_mapping(GroupAccount.where(group_id: target_group_ids, account_id: account_id, role: :moderator), :group_id)
|
||||
end
|
||||
|
||||
def pinned?(status)
|
||||
group_pinned_statuses.where(group_id: status.group_id, status: status).exists?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def follow_mapping(query, field)
|
||||
|
||||
@@ -36,6 +36,9 @@ class Group < ApplicationRecord
|
||||
has_many :group_accounts, inverse_of: :group, dependent: :destroy
|
||||
has_many :accounts, through: :group_accounts
|
||||
|
||||
has_many :group_pinned_statuses, inverse_of: :group, dependent: :destroy
|
||||
has_many :pinned_statuses, source: :status, through: :group_pinned_statuses
|
||||
|
||||
has_many :group_removed_accounts, inverse_of: :group, dependent: :destroy
|
||||
has_many :removed_accounts, source: :account, through: :group_removed_accounts
|
||||
|
||||
|
||||
16
app/models/group_pinned_status.rb
Normal file
16
app/models/group_pinned_status.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: group_pinned_statuses
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# status_id :bigint(8) not null
|
||||
# group_id :bigint(8) not null
|
||||
#
|
||||
|
||||
class GroupPinnedStatus < ApplicationRecord
|
||||
belongs_to :group
|
||||
belongs_to :status
|
||||
|
||||
validates_with GroupPinnedStatusValidator
|
||||
end
|
||||
@@ -389,6 +389,12 @@ class Status < ApplicationRecord
|
||||
StatusPin.select('status_id').where(status_id: status_ids).where(account_id: account_id).each_with_object({}) { |p, h| h[p.status_id] = true }
|
||||
end
|
||||
|
||||
def group_pins_map(status_ids, group_id = nil)
|
||||
unless group_id.nil?
|
||||
GroupPinnedStatus.select('status_id').where(status_id: status_ids).where(group_id: group_id).each_with_object({}) { |p, h| h[p.status_id] = true }
|
||||
end
|
||||
end
|
||||
|
||||
def reload_stale_associations!(cached_items)
|
||||
account_ids = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user