Browse Source

use "is" instead of ===

main
familyfriendlymikey 2 years ago
parent
commit
9be13f30a0
  1. 22
      app/client.imba

22
app/client.imba

@ -64,11 +64,11 @@ tag app
err "adding link", e err "adding link", e
def validate_config def validate_config
throw _ if config.default_bang.id === null throw _ if config.default_bang.id is null
throw _ if config.default_bang.url === null throw _ if config.default_bang.url is null
throw _ if config.default_bang.img === null throw _ if config.default_bang.img is null
throw _ if config.default_bang.name === null throw _ if config.default_bang.name is null
throw _ if config.default_bang.frequency === null throw _ if config.default_bang.frequency is null
def reset_config def reset_config
p "resetting config" p "resetting config"
@ -144,14 +144,14 @@ tag app
return no if loading return no if loading
return no if settings_active return no if settings_active
let query = state.query.trim! let query = state.query.trim!
return no if query === '' return no if query is ''
let split_query = query.split /\s+/ let split_query = query.split /\s+/
return no if split_query.length < 2 return no if split_query.length < 2
yes yes
def create_link_from_text text def create_link_from_text text
text = text.trim! text = text.trim!
throw "text is empty" if text === '' throw "text is empty" if text is ''
let split_text = text.split(/\s+/) let split_text = text.split(/\s+/)
throw "no url provided" if split_text.length < 2 throw "no url provided" if split_text.length < 2
let url = split_text.pop! let url = split_text.pop!
@ -182,7 +182,7 @@ tag app
def handle_edit link def handle_edit link
def edit_link def edit_link
let input = window.prompt "Enter the new link name and url:", "{link.name} {link.url}" let input = window.prompt "Enter the new link name and url:", "{link.name} {link.url}"
return if input === null return if input is null
try try
await update_link link, input await update_link link, input
catch e catch e
@ -195,7 +195,7 @@ tag app
let new_link = await create_link_from_text new_link_text let new_link = await create_link_from_text new_link_text
new_link.frequency = old_link.frequency new_link.frequency = old_link.frequency
let result = await db.links.update old_link.id, new_link let result = await db.links.update old_link.id, new_link
throw "link id not found" if result === 0 throw "link id not found" if result is 0
await reload_db! await reload_db!
imba.commit! imba.commit!
return new_link return new_link
@ -271,9 +271,9 @@ tag app
def handle_click_import e def handle_click_import e
loading = yes loading = yes
let id_exists = do |newid| let id_exists = do |newid|
state.links.some! do |{id}| newid === id state.links.some! do |{id}| newid is id
let filter = do |table, value, key| let filter = do |table, value, key|
table === 'links' and not id_exists value.id table is 'links' and not id_exists value.id
try try
await reload_db! await reload_db!
await db.import(e.target.files[0], { filter }) await db.import(e.target.files[0], { filter })

Loading…
Cancel
Save