saved searches: always show 'Saved searches' link in navbar.

* Always display 'Saved searches' link in subnav bar, even if the user
  hasn't created any saved searches yet.
* Eliminate use of `has_saved_searches` bitpref on users.
This commit is contained in:
evazion
2019-09-22 23:14:55 -05:00
parent 4e4c4d627e
commit a5949a4b28
5 changed files with 3 additions and 35 deletions

View File

@@ -151,8 +151,6 @@ class SavedSearch < ApplicationRecord
belongs_to :user
validates :query, presence: true
validate :validate_count
before_create :update_user_on_create
after_destroy :update_user_on_destroy
before_validation :normalize_query
before_validation :normalize_labels
scope :labeled, ->(label) { label.present? ? where("labels @> string_to_array(?, '~~~~')", label) : where("true") }
@@ -163,18 +161,6 @@ class SavedSearch < ApplicationRecord
end
end
def update_user_on_create
if !user.has_saved_searches?
user.update(has_saved_searches: true)
end
end
def update_user_on_destroy
if user.saved_searches.count == 0
user.update(has_saved_searches: false)
end
end
def disable_labels=(value)
CurrentUser.update(disable_categorized_saved_searches: true) if value.to_s.truthy?
end

View File

@@ -32,6 +32,7 @@ class User < ApplicationRecord
# - disable_tagged_filenames (enabled by 387)
# - enable_recent_searches (enabled by 499)
# - disable_cropped_thumbnails (enabled by 22)
# - has_saved_searches
BOOLEAN_ATTRIBUTES = %w(
is_banned
has_mail