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:
mgabdev
2020-09-10 15:07:01 -05:00
parent 899fe425d4
commit d030783089
20 changed files with 332 additions and 23 deletions

View File

@@ -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)

View File

@@ -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

View 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

View File

@@ -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 = []