about summary refs log tree commit diff
path: root/app/controllers/api/v1/filters_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/api/v1/filters_controller.rb')
-rw-r--r--app/controllers/api/v1/filters_controller.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/controllers/api/v1/filters_controller.rb b/app/controllers/api/v1/filters_controller.rb
index 514f7c8fa..ffef0b920 100644
--- a/app/controllers/api/v1/filters_controller.rb
+++ b/app/controllers/api/v1/filters_controller.rb
@@ -15,6 +15,7 @@ class Api::V1::FiltersController < Api::BaseController
 
   def create
     @filter = current_account.custom_filters.create!(resource_params)
+    toggle_filters
     render json: @filter, serializer: REST::FilterSerializer
   end
 
@@ -24,16 +25,22 @@ class Api::V1::FiltersController < Api::BaseController
 
   def update
     @filter.update!(resource_params)
+    toggle_filters
     render json: @filter, serializer: REST::FilterSerializer
   end
 
   def destroy
     @filter.destroy!
+    toggle_filters
     render_empty
   end
 
   private
 
+  def toggle_filters
+    current_account.user.update!(filters_enabled: !current_account.custom_filters.enabled.blank?)
+  end
+
   def set_filters
     @filters = params['all'].to_i == 1 ? current_account.custom_filters : []
   end