diff --git a/app/controllers/relationships_controller.rb b/app/controllers/relationships_controller.rb index 96cce55e9..6cd6b91da 100644 --- a/app/controllers/relationships_controller.rb +++ b/app/controllers/relationships_controller.rb @@ -42,7 +42,11 @@ class RelationshipsController < ApplicationController end def mutual_relationship? - params[:relationship] == 'mutual' + params[:interrelationship] == 'mutual' + end + + def one_way_relationship? + params[:interrelationship] == 'one_way' end def followed_by_relationship? diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss index 82ccebe05..c0c829609 100644 --- a/app/javascript/styles/mastodon/admin.scss +++ b/app/javascript/styles/mastodon/admin.scss @@ -385,6 +385,7 @@ body, .filters { display: flex; flex-wrap: wrap; + margin-right: -40px; .filter-subset { flex: 0 0 auto; diff --git a/app/javascript/styles/mastodon/rtl.scss b/app/javascript/styles/mastodon/rtl.scss index 6aca7834e..4b30ed2c5 100644 --- a/app/javascript/styles/mastodon/rtl.scss +++ b/app/javascript/styles/mastodon/rtl.scss @@ -346,6 +346,11 @@ body.rtl { text-align: right; } + .filter { + margin-right: 0; + margin-left: -45px; + } + .filters .filter-subset { margin-right: 0; margin-left: 45px; diff --git a/app/models/relationship_filter.rb b/app/models/relationship_filter.rb index 9135ff144..49590efcb 100644 --- a/app/models/relationship_filter.rb +++ b/app/models/relationship_filter.rb @@ -3,6 +3,7 @@ class RelationshipFilter KEYS = %i( relationship + interrelationship status by_domain activity @@ -42,6 +43,8 @@ class RelationshipFilter case key when 'relationship' relationship_scope(value) + when 'interrelationship' + by_interrelationship_scope(value) when 'by_domain' by_domain_scope(value) when 'location' @@ -63,8 +66,6 @@ class RelationshipFilter account.following.eager_load(:account_stat).reorder(nil) when 'followed_by' account.followers.eager_load(:account_stat).reorder(nil) - when 'mutual' - account.followers.eager_load(:account_stat).reorder(nil).merge(Account.where(id: account.following)) when 'invited' Account.joins(user: :invite).merge(Invite.where(user: account.user)).eager_load(:account_stat).reorder(nil) else @@ -72,6 +73,27 @@ class RelationshipFilter end end + def by_interrelationship_scope(value) + case value + when 'mutual' + case params[:relationship] + when 'following' + Account.where(id: account.followers) + when 'followed_by' + Account.where(id: account.following) + end + when 'one_way' + case params[:relationship] + when 'following' + Account.where.not(id: account.followers) + when 'followed_by' + Account.where.not(id: account.following) + end + else + raise "Unknown interrelationship: #{value}" + end + end + def by_domain_scope(value) Account.where(domain: value) end diff --git a/app/views/relationships/show.html.haml b/app/views/relationships/show.html.haml index c82e639e0..5dfa646ec 100644 --- a/app/views/relationships/show.html.haml +++ b/app/views/relationships/show.html.haml @@ -10,7 +10,13 @@ %ul %li= filter_link_to t('relationships.following'), relationship: nil %li= filter_link_to t('relationships.followers'), relationship: 'followed_by' - %li= filter_link_to t('relationships.mutual'), relationship: 'mutual' + + .filter-subset + %strong= t 'relationships.interrelationship' + %ul + %li= filter_link_to t('generic.all'), interrelationship: nil + %li= filter_link_to t('relationships.mutual'), interrelationship: 'mutual' + %li= filter_link_to t('relationships.one_way'), interrelationship: 'one_way' .filter-subset %strong= t 'relationships.status' diff --git a/config/locales/en.yml b/config/locales/en.yml index 3a2d4bcbd..2695fb6eb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1236,11 +1236,13 @@ en: follow_selected_followers: Follow selected followers followers: Followers following: Following + interrelationship: Interrelationship invited: Invited last_active: Last active most_recent: Most recent moved: Moved mutual: Mutual + one_way: One-way primary: Primary relationship: Relationship remove_selected_domains: Remove all followers from the selected domains