Skip to content

Commit

Permalink
Unfix settings.js and add autocomplete user settings properly
Browse files Browse the repository at this point in the history
  • Loading branch information
SeinopSys committed Nov 15, 2020
1 parent 9399312 commit 6a0c79c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions assets/js/search_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ function getAutocompleteSource() {
}

function setupSearchAutocomplete() {
if (store.get('disable_search_ac')) return;

const fields = $$('.js-search-field');

fields.forEach(field => {
Expand Down
5 changes: 1 addition & 4 deletions assets/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ export function setupSettings() {

// Local settings
localCheckboxes.forEach(checkbox => {
const storeKey = checkbox.id.replace('user_', '');
checkbox.checked = store.get(storeKey);

checkbox.addEventListener('change', () => {
store.set(storeKey, checkbox.checked);
store.set(checkbox.id.replace('user_', ''), checkbox.checked);
});
});

Expand Down
1 change: 1 addition & 0 deletions lib/philomena_web/controllers/setting_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ defmodule PhilomenaWeb.SettingController do
|> set_cookie(user_params, "hide_staff_tools", "hide_staff_tools")
|> set_cookie(user_params, "hide_uploader", "hide_uploader")
|> set_cookie(user_params, "extended_search_ac", "extended_search_ac")
|> set_cookie(user_params, "disable_search_ac", "disable_search_ac")
end

defp set_cookie(conn, params, param_name, cookie_name) do
Expand Down
6 changes: 5 additions & 1 deletion lib/philomena_web/templates/setting/edit.html.slime
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ h1 Content Settings
=> label f, :chan_nsfw, "Show NSFW channels"
=> checkbox f, :chan_nsfw, checked: @conn.cookies["chan_nsfw"] == "true"
.fieldlabel: i Show streams marked as NSFW on the channels page.
.field
=> label f, :disable_search_ac, "Disable tag autocompletion on search inputs"
=> checkbox f, :disable_search_ac, checked: @conn.cookies["disable_search_ac"] == "true"
.fieldlabel: i By default the various image search inputs across the site will give you tag suggestions as you type. You can disable this here to revert to the previous behavior.
.field
=> label f, :extended_search_ac, "Autocomplete search fields using extended syntax"
=> checkbox f, :extended_search_ac, checked: @conn.cookies["chan_nsfw"] == "true"
=> checkbox f, :extended_search_ac, checked: @conn.cookies["extended_search_ac"] == "true"
.fieldlabel
i
| By default the search fields on the site autocomplete the same syntax as the tag input, but you can chose to enable the
Expand Down

0 comments on commit 6a0c79c

Please sign in to comment.