diff options
author | Takeshi Umeda <noel.yoshiba@gmail.com> | 2020-11-13 00:58:00 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-12 16:58:00 +0100 |
commit | 2b1a6e734ff42c17fb971cf909509b6b2ad84879 (patch) | |
tree | d94c398b4655d790d3d63faf277a1a0ef5e27c0e /app | |
parent | 4790a126bebddd83cbaf1a8436611536dcc417a0 (diff) |
Add follow selected followers button (#15148)
* Add follow selected followers button * Fix unused variable * Fix i18n normalize
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/relationships_controller.rb | 4 | ||||
-rw-r--r-- | app/models/form/account_batch.rb | 8 | ||||
-rw-r--r-- | app/views/relationships/show.html.haml | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/app/controllers/relationships_controller.rb b/app/controllers/relationships_controller.rb index 0835758f2..031e3241f 100644 --- a/app/controllers/relationships_controller.rb +++ b/app/controllers/relationships_controller.rb @@ -49,7 +49,9 @@ class RelationshipsController < ApplicationController end def action_from_button - if params[:unfollow] + if params[:follow] + 'follow' + elsif params[:unfollow] 'unfollow' elsif params[:remove_from_followers] 'remove_from_followers' diff --git a/app/models/form/account_batch.rb b/app/models/form/account_batch.rb index 7b9e40f68..882770d7c 100644 --- a/app/models/form/account_batch.rb +++ b/app/models/form/account_batch.rb @@ -9,6 +9,8 @@ class Form::AccountBatch def save case action + when 'follow' + follow! when 'unfollow' unfollow! when 'remove_from_followers' @@ -24,6 +26,12 @@ class Form::AccountBatch 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) diff --git a/app/views/relationships/show.html.haml b/app/views/relationships/show.html.haml index 4b1e4fd63..c82e639e0 100644 --- a/app/views/relationships/show.html.haml +++ b/app/views/relationships/show.html.haml @@ -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? |