Browse Source

refactor: ensure functions moved to api are prefixed with .api elsewhere

main
familyfriendlymikey 2 years ago
parent
commit
3a6803564c
  1. 2
      app/components/app-bang.imba
  2. 2
      app/components/app-community-links.imba
  3. 2
      app/components/app-edit.imba
  4. 2
      app/components/app-links.imba
  5. 6
      app/components/app-settings.imba
  6. 2
      app/db.imba
  7. 1
      scripts/api_move.sh

2
app/components/app-bang.imba

@ -4,7 +4,7 @@ tag app-bang
"{active_bang.url}{window.encodeURIComponent(state.query)}" "{active_bang.url}{window.encodeURIComponent(state.query)}"
def handle_bang def handle_bang
await increment_link_frequency state.active_bang await api.increment_link_frequency state.active_bang
window.location.href = encoded_bang_query window.location.href = encoded_bang_query
def render def render

2
app/components/app-community-links.imba

@ -26,7 +26,7 @@ tag app-community-links
def add_community_link link def add_community_link link
await db.links.add link await db.links.add link
await reload_db! await api.reload_db!
imba.commit! imba.commit!
def render def render

2
app/components/app-edit.imba

@ -22,7 +22,7 @@ tag app-edit
save_config! save_config!
state.query = prior_query state.query = prior_query
prior_query = '' prior_query = ''
sort_links! api.sort_links!
def handle_delete def handle_delete
try try

2
app/components/app-links.imba

@ -18,7 +18,7 @@ tag app-links
try try
await window.navigator.clipboard.writeText(s) await window.navigator.clipboard.writeText(s)
state.query = '' state.query = ''
sort_links! api.sort_links!
def handle_cut e def handle_cut e
return unless e.target.selectionStart == e.target.selectionEnd return unless e.target.selectionStart == e.target.selectionEnd

6
app/components/app-settings.imba

@ -45,10 +45,10 @@ tag app-settings
return err "importing db", e return err "importing db", e
for link_text in links for link_text in links
try 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 if name_exists link.name
throw "Name already exists, add manually if you don't mind duplicates." throw "Name already exists, add manually if you don't mind duplicates."
add_link link_text api.add_link link_text
catch e catch e
errors.push "{link_text}\n{e}" errors.push "{link_text}\n{e}"
if errors.length > 0 if errors.length > 0
@ -61,7 +61,7 @@ tag app-settings
def handle_click_export def handle_click_export
loading = yes loading = yes
await reload_db! await api.reload_db!
let links = state.links.map do |link| let links = state.links.map do |link|
api.construct_link_text link api.construct_link_text link
let datetime = new Date!.toString!.split(" ") let datetime = new Date!.toString!.split(" ")

2
app/db.imba

@ -28,7 +28,7 @@ db.version(3).stores({
p "upgrading to fuzzyhome db version 3" p "upgrading to fuzzyhome db version 3"
trans.links.toCollection!.modify! do |link| trans.links.toCollection!.modify! do |link|
try try
link.url = parse_url(link.url).href link.url = api.parse_url(link.url).href
db.version(4).stores({ db.version(4).stores({
links: "++id,display_name,name,is_bang,is_pinned,url,frequency,icon" links: "++id,display_name,name,is_bang,is_pinned,url,frequency,icon"

1
scripts/api_move.sh

@ -0,0 +1 @@
printf "\033c" && rg --pcre2 -g '!api.imba' '(?<!api.)'"$1"
Loading…
Cancel
Save