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 state from './state'
import { config, save_config } from './config'
import { omit, orderBy } from 'lodash'
import { parse_url } from './utils'
import { nanoid } from 'nanoid'
@ -113,3 +114,7 @@ export default new class api
return
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
sort_links!
def handle_input
selection_index = 0
sort_links!
def name_exists new_name
state.links.some! do |{name}| new_name is name

9
app/components/app-links.imba

@ -27,8 +27,9 @@ tag app-links
catch
no
def toggle_effective_names
config.enable_effective_names = !config.enable_effective_names
def handle_input
selection_index = 0
sort_links!
def render
@ -100,7 +101,7 @@ tag app-links
<.header>
<.side.left@click=toggle_effective_names>
<.side.left@click=api.toggle_effective_names>
if config.enable_effective_names
<svg src="../assets/eye.svg">
else
@ -109,7 +110,7 @@ tag app-links
<input$links-input
bind=state.query
@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('esc').capture.if(!state.loading)=handle_esc
@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!
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_import
let errors = []
@ -126,15 +121,13 @@ tag app-settings
@click=handle_click_toggle_buttons
>
config.enable_buttons ? "DISABLE BUTTONS" : "ENABLE BUTTONS"
<.settings-container>
<.settings-button
@click=handle_click_toggle_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-button
@click.if(!loading)=handle_toggle_light_theme

Loading…
Cancel
Save