From 3a6803564c4ee5f672ac056c8a65fc80506628b9 Mon Sep 17 00:00:00 2001 From: familyfriendlymikey Date: Fri, 2 Sep 2022 13:54:07 -0400 Subject: [PATCH] refactor: ensure functions moved to api are prefixed with .api elsewhere --- app/components/app-bang.imba | 2 +- app/components/app-community-links.imba | 2 +- app/components/app-edit.imba | 2 +- app/components/app-links.imba | 2 +- app/components/app-settings.imba | 6 +++--- app/db.imba | 2 +- scripts/api_move.sh | 1 + 7 files changed, 9 insertions(+), 8 deletions(-) create mode 100755 scripts/api_move.sh diff --git a/app/components/app-bang.imba b/app/components/app-bang.imba index f0cae85..51af646 100644 --- a/app/components/app-bang.imba +++ b/app/components/app-bang.imba @@ -4,7 +4,7 @@ tag app-bang "{active_bang.url}{window.encodeURIComponent(state.query)}" def handle_bang - await increment_link_frequency state.active_bang + await api.increment_link_frequency state.active_bang window.location.href = encoded_bang_query def render diff --git a/app/components/app-community-links.imba b/app/components/app-community-links.imba index 0760fcb..b311236 100644 --- a/app/components/app-community-links.imba +++ b/app/components/app-community-links.imba @@ -26,7 +26,7 @@ tag app-community-links def add_community_link link await db.links.add link - await reload_db! + await api.reload_db! imba.commit! def render diff --git a/app/components/app-edit.imba b/app/components/app-edit.imba index b2e1e6f..60a6825 100644 --- a/app/components/app-edit.imba +++ b/app/components/app-edit.imba @@ -22,7 +22,7 @@ tag app-edit save_config! state.query = prior_query prior_query = '' - sort_links! + api.sort_links! def handle_delete try diff --git a/app/components/app-links.imba b/app/components/app-links.imba index 33b8125..9fc8c00 100644 --- a/app/components/app-links.imba +++ b/app/components/app-links.imba @@ -18,7 +18,7 @@ tag app-links try await window.navigator.clipboard.writeText(s) state.query = '' - sort_links! + api.sort_links! def handle_cut e return unless e.target.selectionStart == e.target.selectionEnd diff --git a/app/components/app-settings.imba b/app/components/app-settings.imba index bc72d7e..cca4b74 100644 --- a/app/components/app-settings.imba +++ b/app/components/app-settings.imba @@ -45,10 +45,10 @@ tag app-settings return err "importing db", e for link_text in links try - let link = await create_link_from_text link_text + let link = await api.create_link_from_text link_text if name_exists link.name throw "Name already exists, add manually if you don't mind duplicates." - add_link link_text + api.add_link link_text catch e errors.push "{link_text}\n{e}" if errors.length > 0 @@ -61,7 +61,7 @@ tag app-settings def handle_click_export loading = yes - await reload_db! + await api.reload_db! let links = state.links.map do |link| api.construct_link_text link let datetime = new Date!.toString!.split(" ") diff --git a/app/db.imba b/app/db.imba index 35a406b..bbbbf14 100644 --- a/app/db.imba +++ b/app/db.imba @@ -28,7 +28,7 @@ db.version(3).stores({ p "upgrading to fuzzyhome db version 3" trans.links.toCollection!.modify! do |link| try - link.url = parse_url(link.url).href + link.url = api.parse_url(link.url).href db.version(4).stores({ links: "++id,display_name,name,is_bang,is_pinned,url,frequency,icon" diff --git a/scripts/api_move.sh b/scripts/api_move.sh new file mode 100755 index 0000000..9ab5f40 --- /dev/null +++ b/scripts/api_move.sh @@ -0,0 +1 @@ +printf "\033c" && rg --pcre2 -g '!api.imba' '(?