Browse Source

disable stuff if loading

main
familyfriendlymikey 2 years ago
parent
commit
d731dc34d7
  1. 42
      app/client.imba

42
app/client.imba

@ -269,6 +269,7 @@ tag app
window.location.href = link.url window.location.href = link.url
def handle_return def handle_return
return if editing_link
if bang or state.scored_links.length < 1 if bang or state.scored_links.length < 1
return handle_bang! return handle_bang!
let link = state.scored_links[selection_index] let link = state.scored_links[selection_index]
@ -335,6 +336,7 @@ tag app
handle_edit state.scored_links[selection_index] handle_edit state.scored_links[selection_index]
def handle_shift_return def handle_shift_return
def go
if editing_link if editing_link
try try
await update_link editing_link, state.query await update_link editing_link, state.query
@ -345,6 +347,9 @@ tag app
err "updating link", e err "updating link", e
else else
handle_add! handle_add!
loading = yes
await go!
loading = no
def handle_esc def handle_esc
editing_link = no editing_link = no
@ -427,7 +432,14 @@ tag app
Date!.toString!.split(" ").slice(0, 4).join(" ") Date!.toString!.split(" ").slice(0, 4).join(" ")
def render def render
<self>
css .disabled *
@important c:gray4 cursor:default user-select:none pointer-events:none
css .disabled $main-input
@important bg:gray4/10 bc:gray4
<self .disabled=loading>
css body css body
d:flex fld:column jc:flex-start ai:center d:flex fld:column jc:flex-start ai:center
@ -484,9 +496,6 @@ tag app
css .tip-content css .tip-content
pt:2px fs:14px c:purple3 pt:2px fs:14px c:purple3
css .disabled
c:gray4 cursor:default user-select:none
css .links css .links
d:flex fld:column jc:flex-start fl:1 d:flex fld:column jc:flex-start fl:1
w:100% ofy:auto pt:15px w:100% ofy:auto pt:15px
@ -559,7 +568,7 @@ tag app
@click=(settings_active = no) @click=(settings_active = no)
> "BACK" > "BACK"
<.settings-container> <.settings-container>
<label.settings-button .disabled=loading> <label.settings-button>
"IMPORT" "IMPORT"
<input[d:none] <input[d:none]
disabled=loading disabled=loading
@ -568,16 +577,13 @@ tag app
type="file" type="file"
> >
<.settings-button <.settings-button
.disabled=loading
@click.if(!loading)=handle_click_export @click.if(!loading)=handle_click_export
> "EXPORT" > "EXPORT"
<.settings-container> <.settings-container>
<.settings-button <.settings-button
.disabled=loading
@click.if(!loading)=handle_click_github @click.if(!loading)=handle_click_github
> "TUTORIAL" > "TUTORIAL"
<.settings-button <.settings-button
.disabled=loading
@click.if(!loading)=handle_click_github @click.if(!loading)=handle_click_github
> "GITHUB" > "GITHUB"
<.settings-container> <.settings-container>
@ -600,7 +606,6 @@ tag app
config.enable_effective_names ? "DISABLE EFFECTIVE NAMES" : "ENABLE EFFECTIVE NAMES" config.enable_effective_names ? "DISABLE EFFECTIVE NAMES" : "ENABLE EFFECTIVE NAMES"
<.settings-container> <.settings-container>
<.settings-button <.settings-button
.disabled=loading
@click.if(!loading)=handle_toggle_light_theme @click.if(!loading)=handle_toggle_light_theme
> >
config.enable_dark_theme ? "DISABLE DARK THEME" : "ENABLE DARK THEME" config.enable_dark_theme ? "DISABLE DARK THEME" : "ENABLE DARK THEME"
@ -638,17 +643,16 @@ tag app
<input$main-input <input$main-input
bind=state.query bind=state.query
# placeholder=pretty_date # placeholder=pretty_date
@hotkey('return').capture=handle_return @hotkey('return').capture.if(!loading)=handle_return
@hotkey('shift+return').capture=handle_shift_return @hotkey('shift+return').capture.if(!loading)=handle_shift_return
@hotkey('esc').capture=handle_esc @hotkey('esc').capture.if(!loading)=handle_esc
@hotkey('shift+backspace').capture=handle_shift_backspace @hotkey('shift+backspace').capture.if(!loading)=handle_shift_backspace
@hotkey('down').capture=increment_selection_index @hotkey('down').capture.if(!loading)=increment_selection_index
@hotkey('up').capture=decrement_selection_index @hotkey('up').capture.if(!loading)=decrement_selection_index
@keydown.del=handle_del @keydown.del.if(!loading)=handle_del
@input=handle_input @input.if(!loading)=handle_input
@paste=handle_paste @paste.if(!loading)=handle_paste
@blur=this.focus @blur=this.focus
.disabled=loading
disabled=loading disabled=loading
> >

Loading…
Cancel
Save