about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/settings/preferences_controller.rb2
-rw-r--r--app/models/account.rb2
-rw-r--r--app/models/status.rb6
-rw-r--r--app/models/user.rb5
-rw-r--r--app/views/settings/preferences/show.html.haml2
5 files changed, 10 insertions, 7 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 57793d776..851e62d1b 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -27,7 +27,7 @@ class Settings::PreferencesController < ApplicationController
   def user_params
     params.require(:user).permit(
       :locale,
-      filtered_languages: []
+      chosen_languages: []
     )
   end
 
diff --git a/app/models/account.rb b/app/models/account.rb
index 72e850aa7..c3eea79cc 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -141,7 +141,7 @@ class Account < ApplicationRecord
            prefix: true,
            allow_nil: true
 
-  delegate :filtered_languages, to: :user, prefix: false, allow_nil: true
+  delegate :chosen_languages, to: :user, prefix: false, allow_nil: true
 
   def local?
     domain.nil?
diff --git a/app/models/status.rb b/app/models/status.rb
index 7fa069083..e7dd0df29 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -190,8 +190,8 @@ class Status < ApplicationRecord
   before_validation :set_local
 
   class << self
-    def not_in_filtered_languages(account)
-      where(language: nil).or where.not(language: account.filtered_languages)
+    def in_chosen_languages(account)
+      where(language: nil).or where(language: account.chosen_languages)
     end
 
     def as_home_timeline(account)
@@ -333,7 +333,7 @@ class Status < ApplicationRecord
     def filter_timeline_for_account(query, account, local_only)
       query = query.not_excluded_by_account(account)
       query = query.not_domain_blocked_by_account(account) unless local_only
-      query = query.not_in_filtered_languages(account) if account.filtered_languages.present?
+      query = query.in_chosen_languages(account) if account.chosen_languages.present?
       query.merge(account_silencing_filter(account))
     end
 
diff --git a/app/models/user.rb b/app/models/user.rb
index 0becfa7e9..c95960dc6 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -35,6 +35,7 @@
 #  moderator                 :boolean          default(FALSE), not null
 #  invite_id                 :bigint(8)
 #  remember_token            :string
+#  chosen_languages          :string           is an Array
 #
 
 class User < ApplicationRecord
@@ -317,7 +318,9 @@ class User < ApplicationRecord
   private
 
   def sanitize_languages
-    filtered_languages.reject!(&:blank?)
+    return if chosen_languages.nil?
+    chosen_languages.reject!(&:blank?)
+    self.chosen_languages = nil if chosen_languages.empty?
   end
 
   def prepare_new_user!
diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml
index d2e866373..6ec03ab4b 100644
--- a/app/views/settings/preferences/show.html.haml
+++ b/app/views/settings/preferences/show.html.haml
@@ -12,7 +12,7 @@
   .fields-group
     = f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, selected: I18n.locale
 
-    = f.input :filtered_languages, collection: filterable_languages, wrapper: :with_block_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
+    = f.input :chosen_languages, collection: filterable_languages.sort, wrapper: :with_block_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
 
   %h4= t 'preferences.publishing'