Browse Source

refactor: move toggle_effective_names to api, remove from settings

main
familyfriendlymikey 2 years ago
parent
commit
4cd749ec42
  1. 5
      app/api.imba
  2. 4
      app/client.imba
  3. 9
      app/components/app-links.imba
  4. 11
      app/components/app-settings.imba

5
app/api.imba

@ -1,5 +1,6 @@
import db from './db' import db from './db'
import state from './state' import state from './state'
import { config, save_config } from './config'
import { omit, orderBy } from 'lodash' import { omit, orderBy } from 'lodash'
import { parse_url } from './utils' import { parse_url } from './utils'
import { nanoid } from 'nanoid' import { nanoid } from 'nanoid'
@ -113,3 +114,7 @@ export default new class api
return return
reader.readAsDataURL(blob) reader.readAsDataURL(blob)
def toggle_effective_names
config.enable_effective_names = !config.enable_effective_names
save_config!

4
app/client.imba

@ -231,10 +231,6 @@ tag app
viewing_community_links = no viewing_community_links = no
sort_links! sort_links!
def handle_input
selection_index = 0
sort_links!
def name_exists new_name def name_exists new_name
state.links.some! do |{name}| new_name is name state.links.some! do |{name}| new_name is name

9
app/components/app-links.imba

@ -27,8 +27,9 @@ tag app-links
catch catch
no no
def toggle_effective_names def handle_input
config.enable_effective_names = !config.enable_effective_names selection_index = 0
sort_links!
def render def render
@ -100,7 +101,7 @@ tag app-links
<.header> <.header>
<.side.left@click=toggle_effective_names> <.side.left@click=api.toggle_effective_names>
if config.enable_effective_names if config.enable_effective_names
<svg src="../assets/eye.svg"> <svg src="../assets/eye.svg">
else else
@ -109,7 +110,7 @@ tag app-links
<input$links-input <input$links-input
bind=state.query bind=state.query
@hotkey('return').capture.if(!state.loading)=handle_return @hotkey('return').capture.if(!state.loading)=handle_return
@hotkey('tab').capture.if(!state.loading)=toggle_effective_names @hotkey('tab').capture.if(!state.loading)=api.toggle_effective_names
@hotkey('shift+return').capture.if(!state.loading)=handle_shift_return @hotkey('shift+return').capture.if(!state.loading)=handle_shift_return
@hotkey('esc').capture.if(!state.loading)=handle_esc @hotkey('esc').capture.if(!state.loading)=handle_esc
@hotkey('shift+backspace').capture.if(!state.loading)=handle_shift_backspace @hotkey('shift+backspace').capture.if(!state.loading)=handle_shift_backspace

11
app/components/app-settings.imba

@ -28,11 +28,6 @@ tag app-settings
save_config! save_config!
settings_active = no settings_active = no
def handle_click_toggle_effective_names
config.enable_effective_names = not config.enable_effective_names
save_config!
settings_active = no
def handle_click_import e def handle_click_import e
def handle_import def handle_import
let errors = [] let errors = []
@ -126,15 +121,13 @@ tag app-settings
@click=handle_click_toggle_buttons @click=handle_click_toggle_buttons
> >
config.enable_buttons ? "DISABLE BUTTONS" : "ENABLE BUTTONS" config.enable_buttons ? "DISABLE BUTTONS" : "ENABLE BUTTONS"
<.settings-container> <.settings-container>
<.settings-button <.settings-button
@click=handle_click_toggle_search_on_paste @click=handle_click_toggle_search_on_paste
> >
config.enable_search_on_paste ? "DISABLE SEARCH ON PASTE" : "ENABLE SEARCH ON PASTE" config.enable_search_on_paste ? "DISABLE SEARCH ON PASTE" : "ENABLE SEARCH ON PASTE"
<.settings-button
@click=handle_click_toggle_effective_names
>
config.enable_effective_names ? "DISABLE EFFECTIVE NAMES" : "ENABLE EFFECTIVE NAMES"
<.settings-container> <.settings-container>
<.settings-button <.settings-button
@click.if(!loading)=handle_toggle_light_theme @click.if(!loading)=handle_toggle_light_theme

Loading…
Cancel
Save