From b4e08f656fc094852674b6fb0b455e5e214b1664 Mon Sep 17 00:00:00 2001 From: familyfriendlymikey Date: Sat, 3 Sep 2022 18:59:54 -0400 Subject: [PATCH] refactor --- app/api.imba | 2 +- app/client.imba | 2 ++ app/components/app-bang.imba | 10 +++++++++- app/components/app-edit.imba | 36 ++++++++++++----------------------- app/components/app-home.imba | 9 +++++++-- app/components/app-links.imba | 16 ++++++++-------- app/components/app-tips.imba | 3 ++- 7 files changed, 41 insertions(+), 37 deletions(-) diff --git a/app/api.imba b/app/api.imba index e8a772b..edd8957 100644 --- a/app/api.imba +++ b/app/api.imba @@ -237,4 +237,4 @@ export default new class api def unset_active_bang state.active_bang = no - api.sort_links! + sort_links! diff --git a/app/client.imba b/app/client.imba index 66ebba3..e4fe7f0 100644 --- a/app/client.imba +++ b/app/client.imba @@ -6,6 +6,8 @@ p "fuzzyhome version {version}" # import sw from './sw.imba?serviceworker' # navigator..serviceWorker..register(sw).then! do |reg| reg.update! +p "hehe" + import { nanoid } from 'nanoid' import { err } from './utils' diff --git a/app/components/app-bang.imba b/app/components/app-bang.imba index 4ef5947..0f3d379 100644 --- a/app/components/app-bang.imba +++ b/app/components/app-bang.imba @@ -33,7 +33,7 @@ tag app-bang if state.active_bang <.tip @click=api.unset_active_bang - @hotkey('esc').capture.if(!state.loading)=unset_active_bang + @hotkey('esc').capture.if(!state.loading)=api.unset_active_bang > <.tip-hotkey> "Esc" <.tip-content> "Back" @@ -59,6 +59,14 @@ tag app-bang <.tip-hotkey> "Cut (If No Selection)" <.tip-content> "Cut All Text" + tips.push <> + <.tip + @click.if(!state.loading)=refs.settings.open + @hotkey('shift+tab').capture.if(!state.loading)=refs.settings.open + > + <.tip-hotkey> "Shift + Tab" + <.tip-content> "Toggle Settings" + if state.active_bang tips.push <> <.tip.noclick> diff --git a/app/components/app-edit.imba b/app/components/app-edit.imba index cb355d2..561c00a 100644 --- a/app/components/app-edit.imba +++ b/app/components/app-edit.imba @@ -1,8 +1,11 @@ tag app-edit - get render? do mounted? active = no + def mount + $dn.setSelectionRange 0, 0 + $dn.focus! + def open data link = data new_link_text = value=api.construct_link_text(link) @@ -11,11 +14,6 @@ tag app-edit def close active = no - def mount - setTimeout(&, 40) do - $dn.focus! - imba.commit! - def handle_click_set_default_bang config.set_default_bang link close! @@ -59,23 +57,13 @@ tag app-edit <.tip-hotkey> "Click" <.tip-content> "Set Default Bang" - else - tips.push <> - <.tip - @click=close - @hotkey('esc').capture.if(!state.loading)=close - > - <.tip-hotkey> "Esc" - <.tip-content> "Cancel" - - if link.is_bang - tips.push <> - <.tip - @click=close - @hotkey('esc').capture.if(!state.loading)=close - > - <.tip-hotkey> "Esc" - <.tip-content> "Cancel" + tips.push <> + <.tip + @click=close + @hotkey('esc').capture.if(!state.loading)=close + > + <.tip-hotkey> "Esc" + <.tip-content> "Cancel" tips @@ -85,6 +73,6 @@ tag app-edit css d:flex fld:column gap:20px w:100%
- + diff --git a/app/components/app-home.imba b/app/components/app-home.imba index 63b4df4..a8d15a9 100644 --- a/app/components/app-home.imba +++ b/app/components/app-home.imba @@ -1,7 +1,10 @@ tag app-home def mount - $links-input.focus! + $home-input.focus! + + def blur + setTimeout(&, 100) do $home-input.focus! def handle_paste e return unless config.data.enable_search_on_paste @@ -41,12 +44,14 @@ tag app-home else - if (let m = api.math_result) isnt no diff --git a/app/components/app-links.imba b/app/components/app-links.imba index eaf9070..a15ef4f 100644 --- a/app/components/app-links.imba +++ b/app/components/app-links.imba @@ -14,14 +14,6 @@ tag app-links get tips let tips = [] - tips.push <> - <.tip - @click=api.handle_click_link - @hotkey('return').force.if(!loading)=api.handle_click_link - > - <.tip-hotkey> "Return" - <.tip-content> "Navigate To Link" - tips.push <> <.tip @click=api.handle_add_link @@ -40,6 +32,14 @@ tag app-links else "\"{sq.join " "}\"" + tips.push <> + <.tip + @click=api.handle_click_link + @hotkey('return').force.if(!loading)=api.handle_click_link + > + <.tip-hotkey> "Return" + <.tip-content> "Navigate To Link" + tips.push <> <.tip @click=handle_edit diff --git a/app/components/app-tips.imba b/app/components/app-tips.imba index cace1c3..e383742 100644 --- a/app/components/app-tips.imba +++ b/app/components/app-tips.imba @@ -2,7 +2,8 @@ import { chunk, fill } from 'lodash' tag app-tips - show_more = no + def unmount + show_more = no def toggle show_more = not show_more