Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Add follow selected followers button (mastodon#15148)
Browse files Browse the repository at this point in the history
* Add follow selected followers button

* Fix unused variable

* Fix i18n normalize
  • Loading branch information
noellabo authored Nov 12, 2020
1 parent 4790a12 commit 2b1a6e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/relationships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def filter_params
end

def action_from_button
if params[:unfollow]
if params[:follow]
'follow'
elsif params[:unfollow]
'unfollow'
elsif params[:remove_from_followers]
'remove_from_followers'
Expand Down
8 changes: 8 additions & 0 deletions app/models/form/account_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Form::AccountBatch

def save
case action
when 'follow'
follow!
when 'unfollow'
unfollow!
when 'remove_from_followers'
Expand All @@ -24,6 +26,12 @@ def save

private

def follow!
accounts.find_each do |target_account|
FollowService.new.call(current_account, target_account)
end
end

def unfollow!
accounts.find_each do |target_account|
UnfollowService.new.call(current_account, target_account)
Expand Down
2 changes: 2 additions & 0 deletions app/views/relationships/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
%label.batch-table__toolbar__select.batch-checkbox-all
= check_box_tag :batch_checkbox_all, nil, false
.batch-table__toolbar__actions
= f.button safe_join([fa_icon('user-plus'), t('relationships.follow_selected_followers')]), name: :follow, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } if followed_by_relationship? && !mutual_relationship?

= f.button safe_join([fa_icon('user-times'), t('relationships.remove_selected_follows')]), name: :unfollow, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } unless followed_by_relationship?

= f.button safe_join([fa_icon('trash'), t('relationships.remove_selected_followers')]), name: :remove_from_followers, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') } unless following_relationship?
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ en:
relationships:
activity: Account activity
dormant: Dormant
follow_selected_followers: Follow selected followers
followers: Followers
following: Following
invited: Invited
Expand Down

0 comments on commit 2b1a6e7

Please sign in to comment.