diff --git a/app/api.imba b/app/api.imba index d5f72fc..db166b6 100644 --- a/app/api.imba +++ b/app/api.imba @@ -9,6 +9,7 @@ import { omit, orderBy } from 'lodash' import { nanoid } from 'nanoid' import fzi from 'fzi' import { evaluate as eval_math } from 'mathjs' +import { cloneDeep } from 'lodash' export default new class api @@ -32,6 +33,15 @@ export default new class api p omit(new_link, "icon") return new_link + def put_link link + try + await db.links.update link.id, link + if config.data.default_bang.id is link.id + config.set_default_bang link + await reload_db! + catch e + err "putting link", e + def delete_link link def go try @@ -62,8 +72,9 @@ export default new class api sort_links! def increment_link_frequency link + link.frequency += 1 try - await db.links.update link.id, { frequency: link.frequency + 1 } + await put_link link catch e err "putting link", e diff --git a/app/client.imba b/app/client.imba index 1dc4ba8..66ebba3 100644 --- a/app/client.imba +++ b/app/client.imba @@ -57,6 +57,9 @@ tag app unless global.localStorage.fuzzyhome_visited await api.add_initial_links! + try + let default_bang = await api.add_link '!google search https://www.google.com/search?q=' + config.data.default_bang = default_bang global.localStorage.fuzzyhome_visited = yes try diff --git a/app/components/app-bang.imba b/app/components/app-bang.imba index 0772963..9c3f4a6 100644 --- a/app/components/app-bang.imba +++ b/app/components/app-bang.imba @@ -1,5 +1,9 @@ tag app-bang + def unset_active_bang + state.active_bang = no + api.sort_links! + get bang state.active_bang or config.data.default_bang @@ -13,8 +17,7 @@ tag app-bang def render - css w:100% d:flex fld:column gap:10px - + css w:100% d:flex fld:column gap:15px @@ -46,8 +49,8 @@ tag app-bang if state.active_bang <.tip - @click=(state.active_bang = no) - @hotkey('esc').capture.if(!state.loading)=(state.active_bang = no) + @click=unset_active_bang + @hotkey('esc').capture.if(!state.loading)=unset_active_bang > <.tip-hotkey> "Esc" <.tip-content> "Back" @@ -87,7 +90,7 @@ tag app-bang unless $tips-more.active <.bang.selected@click=handle_bang> css d:flex fld:row jc:space-between ai:center - px:16px py:11px rd:5px cursor:pointer c:blue3 + px:16px py:11px rd:5px cursor:pointer c:#FAD4AB <.link-left> css d:flex fl:1 @@ -96,7 +99,7 @@ tag app-bang css w:20px h:20px mr:10px rd:3px <.display-name> encoded_bang_query - css c:#FAD4AB fs:20px word-break:break-all + css fs:20px word-break:break-all <.link-right> css d:flex fld:row jc:space-between ai:center diff --git a/app/components/app-edit.imba b/app/components/app-edit.imba index d4c3bfd..b4fdbbe 100644 --- a/app/components/app-edit.imba +++ b/app/components/app-edit.imba @@ -16,13 +16,12 @@ tag app-edit imba.commit! def handle_click_set_default_bang - if link.is_bang isnt true + unless link.is_bang return err "setting default bang", "Link is not a bang." config.data.default_bang = link - save_config! - state.query = prior_query - prior_query = '' + config.save! api.sort_links! + close! def handle_delete try @@ -78,7 +77,6 @@ tag app-edit if link.is_bang <.tip @click=handle_click_set_default_bang> css fl:2 - <.tip-hotkey> "Click" <.tip-content> "Set Default Bang" <.tip diff --git a/app/components/app-home.imba b/app/components/app-home.imba index bdab0b4..63b4df4 100644 --- a/app/components/app-home.imba +++ b/app/components/app-home.imba @@ -24,7 +24,7 @@ tag app-home def render - css w:100% d:flex fld:column gap:10px ofy:hidden + css w:100% d:flex fld:column ofy:hidden gap:20px <.header> css d:flex fld:row w:100% diff --git a/app/components/app-links.imba b/app/components/app-links.imba index 64fc3b9..0041e29 100644 --- a/app/components/app-links.imba +++ b/app/components/app-links.imba @@ -14,7 +14,7 @@ tag app-links def render - css w:100% d:flex fld:column gap:10px ofy:hidden + css w:100% d:flex fld:column gap:15px ofy:hidden @@ -69,15 +69,6 @@ tag app-links <.tip-hotkey> "Shift + Tab" <.tip-content> "Toggle Settings" - <.tip.noclick - @hotkey('down').capture.if(!state.loading)=api.increment_link_selection_index - @hotkey('up').capture.if(!state.loading)=api.decrement_link_selection_index - > - <.tip-hotkey> "Up/Down Arrow" - <.tip-content> "Move Selection" - - <.tip-row> - <.tip @click.if(!loading)=api.handle_cut > @@ -88,6 +79,15 @@ tag app-links <.tip-hotkey> "Cut (If No Selection)" <.tip-content> "Cut All Text" + <.tip-row> + + <.tip.noclick + @hotkey('down').capture.if(!state.loading)=api.increment_link_selection_index + @hotkey('up').capture.if(!state.loading)=api.decrement_link_selection_index + > + <.tip-hotkey> "Up/Down Arrow" + <.tip-content> "Move Selection" + <.tip.noclick> <.tip-hotkey> "Paste (If Input Empty)" <.tip-content> "Instant Search" diff --git a/app/components/app-settings.imba b/app/components/app-settings.imba index 250c4e7..1b83555 100644 --- a/app/components/app-settings.imba +++ b/app/components/app-settings.imba @@ -125,21 +125,23 @@ tag app-settings <.settings-button @click.if(!loading)=handle_click_github > "GITHUB" + <.settings-container> - <.settings-button - @click=handle_click_toggle_tips - > + + <.settings-button @click=handle_click_toggle_tips> + let t= p config.data config.data.enable_tips ? "DISABLE TIPS" : "ENABLE TIPS" - <.settings-button - @click=handle_click_toggle_buttons - > + + <.settings-button @click=handle_click_toggle_buttons> config.data.enable_buttons ? "DISABLE BUTTONS" : "ENABLE BUTTONS" <.settings-container> + <.settings-button @click=handle_click_toggle_search_on_paste > config.data.enable_search_on_paste ? "DISABLE SEARCH ON PASTE" : "ENABLE SEARCH ON PASTE" + <.settings-button @click.if(!loading)=handle_toggle_light_theme > diff --git a/app/components/app-tips.imba b/app/components/app-tips.imba index 9d93938..d771a59 100644 --- a/app/components/app-tips.imba +++ b/app/components/app-tips.imba @@ -28,18 +28,24 @@ tag app-tips css >>> .tip-content pt:2px fs:14px c:purple3 - + tag app-tips-more < app-tips - active = no - get hide do !active - def toggle - active = !active + get render? do mounted? - - css d:flex fld:column gap:10px + def mount + active = no + imba.commit! + + get hidden do !active + toggle = do active = !active + open = do active = yes + close = do active = no + + + css d:flex fld:column gap:15px <@click=toggle> css w:100% d:flex ja:center c:purple3 rdb:4px cursor:pointer @@ -55,7 +61,7 @@ tag app-tips-more < app-tips <.more> - css d:flex fld:column gap:10px - if hide + css d:flex fld:column gap:15px + if hidden css d:none diff --git a/app/config.imba b/app/config.imba index c3373e6..effc0b8 100644 --- a/app/config.imba +++ b/app/config.imba @@ -23,5 +23,9 @@ export default new class config p "config:", this.data + def set_default_bang bang + data.default_bang = bang + save! + def save global.localStorage.fuzzyhome_config = JSON.stringify(this.data)