commit 8d15fd0ffcec2d9266eb8d72433e47acd8580462 parent 2733928260a7ebe49dfa4111fb4cfbad45d38cfa Author: triesap <137732411+triesap@users.noreply.github.com> Date: Sun, 8 Dec 2024 08:51:30 +0000 Edit async functions add error catch handler. Add app icons. Diffstat:
69 files changed, 264 insertions(+), 269 deletions(-)
diff --git a/crates/tauri/icons/128x128.png b/crates/tauri/icons/128x128.png Binary files differ. diff --git a/crates/tauri/icons/128x128@2x.png b/crates/tauri/icons/128x128@2x.png Binary files differ. diff --git a/crates/tauri/icons/32x32.png b/crates/tauri/icons/32x32.png Binary files differ. diff --git a/crates/tauri/icons/Square107x107Logo.png b/crates/tauri/icons/Square107x107Logo.png Binary files differ. diff --git a/crates/tauri/icons/Square142x142Logo.png b/crates/tauri/icons/Square142x142Logo.png Binary files differ. diff --git a/crates/tauri/icons/Square150x150Logo.png b/crates/tauri/icons/Square150x150Logo.png Binary files differ. diff --git a/crates/tauri/icons/Square284x284Logo.png b/crates/tauri/icons/Square284x284Logo.png Binary files differ. diff --git a/crates/tauri/icons/Square30x30Logo.png b/crates/tauri/icons/Square30x30Logo.png Binary files differ. diff --git a/crates/tauri/icons/Square310x310Logo.png b/crates/tauri/icons/Square310x310Logo.png Binary files differ. diff --git a/crates/tauri/icons/Square44x44Logo.png b/crates/tauri/icons/Square44x44Logo.png Binary files differ. diff --git a/crates/tauri/icons/Square71x71Logo.png b/crates/tauri/icons/Square71x71Logo.png Binary files differ. diff --git a/crates/tauri/icons/Square89x89Logo.png b/crates/tauri/icons/Square89x89Logo.png Binary files differ. diff --git a/crates/tauri/icons/StoreLogo.png b/crates/tauri/icons/StoreLogo.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-hdpi/ic_launcher.png b/crates/tauri/icons/android/mipmap-hdpi/ic_launcher.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-hdpi/ic_launcher_foreground.png b/crates/tauri/icons/android/mipmap-hdpi/ic_launcher_foreground.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-hdpi/ic_launcher_round.png b/crates/tauri/icons/android/mipmap-hdpi/ic_launcher_round.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-mdpi/ic_launcher.png b/crates/tauri/icons/android/mipmap-mdpi/ic_launcher.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-mdpi/ic_launcher_foreground.png b/crates/tauri/icons/android/mipmap-mdpi/ic_launcher_foreground.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-mdpi/ic_launcher_round.png b/crates/tauri/icons/android/mipmap-mdpi/ic_launcher_round.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-xhdpi/ic_launcher.png b/crates/tauri/icons/android/mipmap-xhdpi/ic_launcher.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-xhdpi/ic_launcher_foreground.png b/crates/tauri/icons/android/mipmap-xhdpi/ic_launcher_foreground.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-xhdpi/ic_launcher_round.png b/crates/tauri/icons/android/mipmap-xhdpi/ic_launcher_round.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-xxhdpi/ic_launcher.png b/crates/tauri/icons/android/mipmap-xxhdpi/ic_launcher.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png b/crates/tauri/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-xxhdpi/ic_launcher_round.png b/crates/tauri/icons/android/mipmap-xxhdpi/ic_launcher_round.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-xxxhdpi/ic_launcher.png b/crates/tauri/icons/android/mipmap-xxxhdpi/ic_launcher.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png b/crates/tauri/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png Binary files differ. diff --git a/crates/tauri/icons/android/mipmap-xxxhdpi/ic_launcher_round.png b/crates/tauri/icons/android/mipmap-xxxhdpi/ic_launcher_round.png Binary files differ. diff --git a/crates/tauri/icons/icon.icns b/crates/tauri/icons/icon.icns Binary files differ. diff --git a/crates/tauri/icons/icon.ico b/crates/tauri/icons/icon.ico Binary files differ. diff --git a/crates/tauri/icons/icon.png b/crates/tauri/icons/icon.png Binary files differ. diff --git a/package.json b/package.json @@ -6,12 +6,9 @@ "scripts": { "build:dev": "vite build --mode development", "build": "vite build --mode production", - "prepare:native": "npm run gen", - "prepare:web": "npm run gen", "dev:serve": "vite dev --mode development --debug hmr", "prod:serve": "vite dev --mode production", "dev": "", - "gen": "", "sql:wasm": "rsync -u node_modules/sql.js/dist/sql-wasm.wasm static", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", diff --git a/src/lib/components/image_upload_add_photo.svelte b/src/lib/components/image_upload_add_photo.svelte @@ -1,6 +1,6 @@ <script lang="ts"> import { dialog } from "$lib/client"; - import { Glyph, ls } from "@radroots/svelte-lib"; + import { catch_err, Glyph, ls } from "@radroots/svelte-lib"; export let photo_path: string; @@ -10,7 +10,7 @@ if (!photo_paths_open) return; photo_path = photo_paths_open.results[0]; } catch (e) { - console.log(`(error) handle_photo_add `, e); + await catch_err(e, `handle_photo_add`); } }; </script> diff --git a/src/lib/components/image_upload_control.svelte b/src/lib/components/image_upload_control.svelte @@ -1,6 +1,12 @@ <script lang="ts"> import { dialog, fs } from "$lib/client"; - import { app_layout, Glyph, ImageBlob, ls } from "@radroots/svelte-lib"; + import { + app_layout, + catch_err, + Glyph, + ImageBlob, + ls, + } from "@radroots/svelte-lib"; import { list_assign } from "@radroots/utils"; import { fade } from "svelte/transition"; @@ -35,7 +41,7 @@ if (!photo_paths_select) return; photo_paths = list_assign(photo_paths, photo_paths_select.results); } catch (e) { - console.log(`(error) handle_photo_add `, e); + await catch_err(e, `handle_photo_add`); } }; @@ -50,7 +56,7 @@ file_path: photo_paths[opts_photo_index], }; } catch (e) { - console.log(`(error) handle_photo_envelope_edit `, e); + await catch_err(e, `handle_photo_envelope_edit`); } }; </script> diff --git a/src/lib/components/image_upload_edit_envelope.svelte b/src/lib/components/image_upload_edit_envelope.svelte @@ -1,6 +1,7 @@ <script lang="ts"> import { fs } from "$lib/client"; import { + catch_err, envelope_tilt, envelope_visible, EnvelopeLower, @@ -42,7 +43,7 @@ try { photo_paths = list_move_index(photo_paths, opts_photo_index, 0); } catch (e) { - console.log(`(error) handle_photo_edit_move `, e); + await catch_err(e, `handle_photo_edit_move`); } }; </script> diff --git a/src/lib/components/map_point_select.svelte b/src/lib/components/map_point_select.svelte @@ -2,7 +2,7 @@ import { geoc } from "$lib/client"; import { cfg } from "$lib/conf"; import type { GeocoderReverseResult } from "@radroots/geocoder"; - import { app_thc } from "@radroots/svelte-lib"; + import { app_thc, catch_err } from "@radroots/svelte-lib"; import { MapLibre, Marker } from "@radroots/svelte-maplibre"; import type { GeolocationCoordinatesPoint } from "@radroots/utils"; import MapMarkerDot from "./map_marker_dot.svelte"; @@ -35,7 +35,7 @@ map_geoc = geoc_res.results[0]; else map_geoc = undefined; } catch (e) { - console.log(`(error) map choose location`, e); + await catch_err(e, ``); } })(); } diff --git a/src/lib/components/map_point_select_envelope.svelte b/src/lib/components/map_point_select_envelope.svelte @@ -4,6 +4,7 @@ import type { GeocoderReverseResult } from "@radroots/geocoder"; import { app_thc, + catch_err, envelope_tilt, envelope_visible, EnvelopeLower, @@ -74,7 +75,7 @@ map_point_select_geoc = geoc_res.results[0]; else map_point_select_geoc = undefined; } catch (e) { - console.log(`(error) map choose location`, e); + await catch_err(e, ``); } })(); } diff --git a/src/lib/components/trade_product_list_card.svelte b/src/lib/components/trade_product_list_card.svelte @@ -4,6 +4,7 @@ import { fmt_location_gcs } from "@radroots/models"; import { app_layout, + catch_err, el_id, els_id_pref_index, fmt_geol_latitude, @@ -45,7 +46,6 @@ el: EventTarget & HTMLButtonElement, ): Promise<void> => { try { - // if (media_uploads?.length) return; el.focus(); el_c.scrollTo(); el_id( @@ -60,7 +60,7 @@ (el) => el.classList.add(`translate-y-12`), ); } catch (e) { - console.log(`(error) handle_display_focus `, e); + await catch_err(e, `handle_display_focus`); } }; @@ -75,7 +75,7 @@ (el) => el.classList.remove(`translate-y-12`), ); } catch (e) { - console.log(`(error) handle_display_blur `, e); + await catch_err(e, `handle_display_blur`); } }; </script> diff --git a/src/lib/util/client.ts b/src/lib/util/client.ts @@ -1,5 +1,5 @@ import { db, keystore } from "$lib/client"; -import { app_notify, el_id, route, sleep, type NavigationRoute } from "@radroots/svelte-lib"; +import { app_notify, catch_err, el_id, route, sleep, type NavigationRoute } from "@radroots/svelte-lib"; import type { ThemeLayer } from "@radroots/theme"; import type { ErrorMessage } from "@radroots/utils"; @@ -9,7 +9,7 @@ export const keystore_reset = async (): Promise<ErrorMessage<string> | undefined if (`err` in ks_keys) return ks_keys; for (const ks_key of ks_keys.results) await keystore.remove(ks_key); } catch (e) { - console.log(`(error) keystore_reset `, e); + await catch_err(e, `keystore_reset`); } }; @@ -22,7 +22,7 @@ export const restart = async (opts?: { if (opts?.route) await route(opts.route); else location.reload(); } catch (e) { - console.log(`(error) restart `, e); + await catch_err(e, `restart`); } }; @@ -47,7 +47,7 @@ export const reset_device = async (): Promise<ErrorMessage<string> | undefined> for (const { id } of nostr_relays.results) await db.nostr_relay_delete({ id }); await route(`/`); } catch (e) { - console.log(`(error) reset_device `, e); + await catch_err(e, `reset_device`); } }; @@ -60,6 +60,6 @@ export const el_focus = async (id: string, callback: () => Promise<void>, layer: await callback(); el?.classList.remove(`entry-layer-${layer}-highlight`); } catch (e) { - console.log(`(error) el_focus `, e); + await catch_err(e, `el_focus`); } -}; -\ No newline at end of file +}; diff --git a/src/lib/util/error.ts b/src/lib/util/error.ts @@ -1,16 +1,9 @@ import type { ErrorMessage } from "@radroots/utils"; -export const throw_err = (param: string | ErrorMessage<string>, cause: string = ``): void => { - if (typeof param === `string`) throw new Error(param, { cause }); - else if (`err` in param) throw new Error(param.err, { cause }); +export const throw_err = (param: string | ErrorMessage<string>): undefined => { + if (typeof param === `string`) throw new Error(param); + else throw new Error(param.err); }; -export const catch_err = async (e: unknown, fn_name: string): Promise<void> => { - if (e instanceof Error) { - console.error(`(catch_err) `, e.name, e.message, e.stack, e.cause) - } else { - console.log(`(catch_err) `, e) - } - //@todo -}; + diff --git a/src/lib/util/fetch-radroots-profile.ts b/src/lib/util/fetch-radroots-profile.ts @@ -1,9 +1,9 @@ import { PUBLIC_RADROOTS_URL } from "$env/static/public"; import { http, nostr } from "$lib/client"; import { cfg } from "$lib/conf"; -import { get_store, ls, } from "@radroots/svelte-lib"; +import { catch_err, get_store, ls, } from "@radroots/svelte-lib"; import { err_msg, type ErrorMessage } from "@radroots/utils"; -import { catch_err, throw_err } from "./error"; +import { throw_err } from "./error"; export const fetch_radroots_profile_validate = async (opts: { profile_name: string; diff --git a/src/lib/util/fetch.ts b/src/lib/util/fetch.ts @@ -2,7 +2,7 @@ import { db, fs, http, keystore } from "$lib/client"; import { cfg, ks } from "$lib/conf"; import type { IClientHttpResponseError } from "@radroots/client"; import { parse_nostr_relay_form_keys, type NostrRelayFormFields } from "@radroots/models"; -import { app_nostr_key, get_store, nostr_relays_connected, nostr_relays_poll_documents, nostr_relays_poll_documents_count } from "@radroots/svelte-lib"; +import { app_nostr_key, catch_err, get_store, nostr_relays_connected, nostr_relays_poll_documents, nostr_relays_poll_documents_count } from "@radroots/svelte-lib"; import { err_msg, err_res, nostr_event_sign_attest, parse_nostr_relay_information_document_fields, type ErrorMessage, type ErrorResponse, type FilePath } from "@radroots/utils"; export const fetch_put_upload = async (opts: { @@ -51,7 +51,7 @@ export const fetch_put_upload = async (opts: { } return err_msg(`error.client.request_unhandled`); } catch (e) { - console.log(`(error) fetch_put_upload `, e); + await catch_err(e, `fetch_put_upload`); return err_msg(`error.client.network_failure`); } }; @@ -75,7 +75,6 @@ export const fetch_relay_documents = async (): Promise<void> => { list: [`on_profile`, { public_key: $app_nostr_key }], }); if (`err` in nostr_relays) throw new Error(nostr_relays.err); - const unconnected_relays = nostr_relays.results.filter( (i) => !$nostr_relays_connected.includes(i.id), ); @@ -83,7 +82,6 @@ export const fetch_relay_documents = async (): Promise<void> => { nostr_relays_poll_documents.set(false); return; } - for (const nostr_relay of unconnected_relays) { const res = await http.fetch({ url: nostr_relay.url.replace(`ws://`, `http://`), @@ -119,12 +117,11 @@ export const fetch_relay_documents = async (): Promise<void> => { ); } } - setTimeout( fetch_relay_documents, cfg.delay.nostr_relay_poll_document, ); } catch (e) { - console.log(`(error) fetch_relay_documents `, e); + await catch_err(e, `fetch_relay_documents`); } -}; -\ No newline at end of file +}; diff --git a/src/lib/util/geocode.ts b/src/lib/util/geocode.ts @@ -1,6 +1,7 @@ import { geoc } from "$lib/client"; import type { GeocoderReverseResult } from "@radroots/geocoder"; import type { LocationGcs } from "@radroots/models"; +import { catch_err } from "@radroots/svelte-lib"; import type { GeolocationCoordinatesPoint } from "@radroots/utils"; export const geoc_rev = async (point: GeolocationCoordinatesPoint): Promise<GeocoderReverseResult | undefined> => { @@ -9,10 +10,11 @@ export const geoc_rev = async (point: GeolocationCoordinatesPoint): Promise<Geoc if (`results` in geoc_res && geoc_res.results.length > 0) return geoc_res.results[0]; } catch (e) { - console.log(`(error) geoc_rev `, e); + await catch_err(e, `geoc_rev`); } }; + export const location_gcs_to_geoc = (opts: LocationGcs): GeocoderReverseResult | undefined => { const { gc_id: id, diff --git a/src/lib/util/kv.ts b/src/lib/util/kv.ts @@ -1,4 +1,4 @@ -import { fmt_id, kv } from "@radroots/svelte-lib"; +import { catch_err, fmt_id, kv } from "@radroots/svelte-lib"; export const kv_init_app = async (): Promise<void> => { try { @@ -6,7 +6,7 @@ export const kv_init_app = async (): Promise<void> => { const kv_list = await kv.each({ range }, `keys`); await Promise.all(kv_list.map((i) => kv.delete(i))); } catch (e) { - console.log(`(error) kv_init_page `, e); + await catch_err(e, `kv_init_app`); } }; @@ -17,14 +17,16 @@ export const kv_init_page = async (): Promise<void> => { const kv_list = await kv.each({ range }, `keys`); await Promise.all(kv_list.map((i) => kv.delete(i))); } catch (e) { - console.log(`(error) kv_init_page `, e); + await catch_err(e, `kv_init_page`); } }; export const kv_sync = async (list: [string, string][]): Promise<void> => { try { for (const [key, val] of list) await kv.set(key, val); + } catch (e) { - console.log(`(error) kv_sync `, e); + await catch_err(e, `kv_sync`); } -}; -\ No newline at end of file +}; + diff --git a/src/lib/util/models-media-upload.ts b/src/lib/util/models-media-upload.ts @@ -2,18 +2,16 @@ import { PUBLIC_RADROOTS_URL } from "$env/static/public"; import { db } from "$lib/client"; import type { IDialogAlert, IDialogConfirm } from "$lib/types"; import type { IClientHttpResponseError } from "@radroots/client"; -import { ls } from "@radroots/svelte-lib"; +import { catch_err, ls } from "@radroots/svelte-lib"; import { parse_file_path, type FilePath, type ResultsList } from "@radroots/utils"; import { get } from "svelte/store"; import { fetch_put_upload } from "./fetch"; - export const model_media_upload_add_list = async (opts: { photo_paths: string[]; }): Promise<IDialogAlert | IDialogConfirm | ResultsList<string>> => { - const $ls = get(ls); - try { + const $ls = get(ls); if (!opts.photo_paths.length) { return { alert: `No photos provided` @@ -109,9 +107,10 @@ export const model_media_upload_add_list = async (opts: { results }; } catch (e) { - console.log(`(error) model_media_upload_add_list `, e); + await catch_err(e, `model_media_upload_add_list`); return { alert: `Failed to upload photos` //@todo } } -}; -\ No newline at end of file +}; + diff --git a/src/lib/util/models-trade-product.ts b/src/lib/util/models-trade-product.ts @@ -1,5 +1,5 @@ import { parse_trade_product_form_keys, trade_product_form_fields, trade_product_form_vals, type IModelsForm, type TradeProductFormFields } from "@radroots/models"; -import { fmt_id, kv } from "@radroots/svelte-lib"; +import { catch_err, fmt_id, kv } from "@radroots/svelte-lib"; import { err_msg, obj_en, type ErrorMessage, type ResultPass } from "@radroots/utils"; const trade_products_field_validate = (field_basis: IModelsForm, field_val: string): boolean => { @@ -29,7 +29,7 @@ export const trade_product_fields_assign = async (opts?: { if (opts?.field_defaults && opts?.field_defaults?.length > 0) for (const [field_k, field_v] of opts?.field_defaults) if (!fields[field_k]) fields[field_k] = field_v; return fields; } catch (e) { - console.log(`(error) trade_product_fields_assign `, e); + await catch_err(e, `trade_product_fields_assign`); return err_msg(String(e)) } }; @@ -58,11 +58,12 @@ export const trade_product_fields_validate = async (opts: { } return fields; } catch (e) { - console.log(`(error) trade_product_fields_validate `, e); + await catch_err(e, `trade_product_fields_validate`); return err_msg(String(e)) } }; + export const tradeproduct_validate_kv = async (opts?: { kv_pref?: string; fields_pass?: string[] | true; @@ -84,12 +85,12 @@ export const tradeproduct_validate_kv = async (opts?: { } return vals; } catch (e) { - console.log(`(error) tradeproduct_validate_kv `, e); + await catch_err(e, `tradeproduct_validate_kv`); return err_msg(String(e)) + } }; - export const tradeproduct_init_kv = async (kv_pref: string): Promise<void> => { try { for (const [field_k, _] of obj_en(trade_product_form_fields, parse_trade_product_form_keys)) { @@ -98,10 +99,11 @@ export const tradeproduct_init_kv = async (kv_pref: string): Promise<void> => { await kv.delete(field_id); } } catch (e) { - console.log(`(error) tradeproduct_init_kv `, e); + await catch_err(e, `tradeproduct_init_kv`); } }; + export const tradeproduct_validate_fields = async (opts: { kv_pref: string; fields: string[]; @@ -115,7 +117,7 @@ export const tradeproduct_validate_fields = async (opts: { } return { pass: true }; } catch (e) { - console.log(`(error) tradeproduct_validate_fields `, e); + await catch_err(e, `tradeproduct_validate_fields`); return err_msg(String(e)) } -}; -\ No newline at end of file +}; diff --git a/src/lib/util/models.ts b/src/lib/util/models.ts @@ -2,10 +2,12 @@ import { db, geoc } from "$lib/client"; import type { IClientGeolocationPosition } from "@radroots/client"; import type { GeocoderReverseResult } from "@radroots/geocoder"; import type { ILocationGcsAddResolve, LocationGcsFormFields } from "@radroots/models"; +import { catch_err } from "@radroots/svelte-lib"; import { err_msg, location_geohash, type GeolocationCoordinatesPoint } from "@radroots/utils"; export const model_location_gcs_add_position = async (opts: { label?: string; + kind: string; geo_pos: IClientGeolocationPosition; }): Promise<ILocationGcsAddResolve<string>> => { try { @@ -14,6 +16,7 @@ export const model_location_gcs_add_position = async (opts: { lat: geo_pos.lat.toString(), lng: geo_pos.lng.toString(), geohash: location_geohash(geo_pos), + kind: opts.kind, } if (label) fields.label = label; const geoc_rev = await geoc.reverse({ @@ -34,13 +37,14 @@ export const model_location_gcs_add_position = async (opts: { const res = await db.location_gcs_add(fields); return res; } catch (e) { - console.log(`(error) model_location_gcs_add_position `, e); + await catch_err(e, `model_location_gcs_add_position`); return err_msg(`*`) } }; export const model_location_gcs_add_geocode = async (opts: { label?: string; + kind: string; geo_code: GeocoderReverseResult; point: GeolocationCoordinatesPoint; }): Promise<ILocationGcsAddResolve<string>> => { @@ -50,6 +54,7 @@ export const model_location_gcs_add_geocode = async (opts: { lat: point.lat.toString(), lng: point.lng.toString(), geohash: location_geohash(point), + kind: opts.kind, gc_id: geo_code.id.toString(), gc_name: geo_code.name, gc_admin1_id: geo_code.admin1_id.toString(), @@ -61,7 +66,7 @@ export const model_location_gcs_add_geocode = async (opts: { const res = await db.location_gcs_add(fields); return res; } catch (e) { - console.log(`(error) model_location_gcs_add_geocode `, e); + await catch_err(e, `model_location_gcs_add_geocode`); return err_msg(`*`) } }; diff --git a/src/lib/util/nostr-sync.ts b/src/lib/util/nostr-sync.ts @@ -3,7 +3,7 @@ import { err, nostr_client, root_symbol } from "$lib/conf"; import { NDKKind } from "@nostr-dev-kit/ndk"; import type { NostrRelay } from "@radroots/models"; import { - app_nostr_key, ls, ndk, ndk_user, nostr_sync_prevent + app_nostr_key, catch_err, ls, ndk, ndk_user, nostr_sync_prevent } from "@radroots/svelte-lib"; import { fmt_tags_basis_nip99, ndk_event, ndk_event_metadata, nevent_encode, num_str } from "@radroots/utils"; import { get as get_store } from "svelte/store"; @@ -25,14 +25,14 @@ export const nostr_sync_metadata = async (): Promise<void> => { }); if (ev_metadata) await ev_metadata.publish(); } catch (e) { - console.log(`(error) nostr_sync_metadata `, e); + await catch_err(e, `nostr_sync_metadata`); } }; export const nostr_sync_classified = async (nostr_relays: NostrRelay[]): Promise<void> => { - const $ndk = get_store(ndk); - const $ndk_user = get_store(ndk_user); try { + const $ndk = get_store(ndk); + const $ndk_user = get_store(ndk_user); const trade_products_all = await db.trade_product_get({ list: [`all`], }); @@ -104,15 +104,15 @@ export const nostr_sync_classified = async (nostr_relays: NostrRelay[]): Promise } } } catch (e) { - console.log(`(error) nostr_sync_classified `, e); + await catch_err(e, `nostr_sync_classified`); } }; export const nostr_sync = async (): Promise<void> => { - const $nostr_sync_prevent = get_store(nostr_sync_prevent); - const $ls = get_store(ls); - const $app_nostr_key = get_store(app_nostr_key); try { + const $nostr_sync_prevent = get_store(nostr_sync_prevent); + const $ls = get_store(ls); + const $app_nostr_key = get_store(app_nostr_key); if ($nostr_sync_prevent) { const confirm = await dialog.confirm({ message: `${$ls(`error.client.nostr_sync_disabled`)}`, @@ -135,10 +135,11 @@ export const nostr_sync = async (): Promise<void> => { await nostr_sync_classified(nostr_relays.results); console.log(`nostr_sync done`) } catch (e) { - console.log(`(error) nostr_sync `, e); + await catch_err(e, `nostr_sync`); } }; + export const nostr_tags_basis = (): string[][] => { const tags: string[][] = []; for (const tag of [`app${device.metadata?.version ? `/${device.metadata.version}` : ``}`]) tags.push([root_symbol, tag]) diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte @@ -9,6 +9,7 @@ app_init, app_nostr_key, app_splash, + catch_err, ndk, ndk_user, nostr_ndk_configured, @@ -44,7 +45,7 @@ await sleep(cfg.delay.load_notify); await notification.init(); } catch (e) { - console.log(`(app_init) error `, e); + await catch_err(e, `app_init-subscribe`); } }); @@ -77,7 +78,7 @@ $ndk_user.ndk = $ndk; nostr_ndk_configured.set(true); } catch (e) { - console.log(`(error) app_nostr_key`, e); + await catch_err(e, `app_nostr_key-subscribe`); } }); @@ -88,7 +89,7 @@ nostr_relays_poll_documents.set(true); await nostr_sync(); } catch (e) { - console.log(`(nostr_ndk_configured) error `, e); + await catch_err(e, `nostr_ndk_configured-subscribe`); } }); @@ -98,7 +99,7 @@ if (!_nostr_relays_poll_documents) return; await fetch_relay_documents(); } catch (e) { - console.log(`(error) nostr_relays_poll_documents`, e); + await catch_err(e, `nostr_relays_poll_documents-subscribe`); } }, ); diff --git a/src/routes/(app)/+layout.ts b/src/routes/(app)/+layout.ts @@ -1,9 +1,9 @@ import { keystore } from '$lib/client'; import { ks } from '$lib/conf'; -import { app_cfg_type, app_nostr_key, app_splash, parse_cfg_type, route } from '@radroots/svelte-lib'; +import { app_cfg_type, app_nostr_key, app_splash, catch_err, parse_cfg_type, route } from '@radroots/svelte-lib'; import type { LayoutLoad, LayoutLoadEvent } from './$types'; -export const load: LayoutLoad = async ({ url }: LayoutLoadEvent) => { +export const load: LayoutLoad = async (_: LayoutLoadEvent) => { try { const ks_nostr_publickey = await keystore.get( ks.keys.nostr_publickey, @@ -29,9 +29,8 @@ export const load: LayoutLoad = async ({ url }: LayoutLoadEvent) => { app_splash.set(false); app_nostr_key.set(ks_nostr_publickey.result); } catch (e) { - console.log(`(load) (conf) app ERROR`, e) + await catch_err(e, `(app)load`) } finally { - //await win.splash_hide(); return {}; }; }; diff --git a/src/routes/(app)/farm/land/+page.svelte b/src/routes/(app)/farm/land/+page.svelte @@ -8,6 +8,7 @@ PageHeader, TabsFloat, app_notify, + catch_err, ls, route, } from "@radroots/svelte-lib"; @@ -39,7 +40,7 @@ location_gcss: location_gcss.results, } satisfies LoadData; } catch (e) { - console.log(`(error) load_data `, e); + await catch_err(e, `load_data`); } }; </script> diff --git a/src/routes/(app)/farm/land/add/+page.svelte b/src/routes/(app)/farm/land/add/+page.svelte @@ -1,6 +1,7 @@ <script lang="ts"> import { dialog, geol } from "$lib/client"; import MapPointSelect from "$lib/components/map_point_select.svelte"; + import { kv_init_page } from "$lib/util/kv"; import type { IClientGeolocationPosition } from "@radroots/client"; import type { GeocoderReverseResult } from "@radroots/geocoder"; import { @@ -9,12 +10,13 @@ carousel_inc, carousel_index, carousel_init, + catch_err, Fade, fmt_geol_latitude, fmt_geol_longitude, fmt_id, Glyph, - GlyphTitleSelect, + GlyphTitleSelectLabel, InputElement, LayoutView, ls, @@ -34,7 +36,7 @@ let lgcs_label = ``; let lgcs_area = ``; - let lgcs_area_unit = `ac`; + let lgcs_area_unit = `ha`; let lgcs_elevation = ``; let lgcs_elevation_unit = `m`; let lgcs_climate = ``; @@ -54,6 +56,7 @@ const init_page = async (): Promise<void> => { try { + await kv_init_page(); carousel_init(1); const geolc = await geol.current(); if (`err` in geolc) { @@ -64,7 +67,7 @@ } geol_pos = geolc; } catch (e) { - console.log(`(error) init_page `, e); + await catch_err(e, `init_page`); } }; @@ -72,7 +75,7 @@ try { await carousel_inc(view); } catch (e) { - console.log(`(error) handle_inc `, e); + await catch_err(e, `handle_inc`); } }; @@ -80,7 +83,7 @@ try { await carousel_dec(view); } catch (e) { - console.log(`(error) handle_dec `, e); + await catch_err(e, `handle_dec`); } }; </script> @@ -291,7 +294,7 @@ }} > <svelte:fragment slot="element"> - <GlyphTitleSelect + <GlyphTitleSelectLabel basis={{ label: `${$ls(`measurement.area.${lgcs_area_unit}_ab`)}`, }} @@ -351,7 +354,7 @@ }} > <svelte:fragment slot="element"> - <GlyphTitleSelect + <GlyphTitleSelectLabel basis={{ label: `${$ls(`measurement.length.${lgcs_elevation_unit}_ab`)}`, }} @@ -369,7 +372,7 @@ sync: true, layer: 0, classes: `h-10 placeholder:text-[1.1rem]`, - placeholder: `Approx. elevation`, + placeholder: `Elevation`, field: { charset: regex.num, validate: regex.num, diff --git a/src/routes/(app)/models/location-gcs/+page.svelte b/src/routes/(app)/models/location-gcs/+page.svelte @@ -3,6 +3,7 @@ import { type LocationGcs } from "@radroots/models"; import { app_notify, + catch_err, LayoutTrellis, LayoutView, ls, @@ -24,10 +25,6 @@ } }); - $: { - console.log(JSON.stringify(ld, null, 4), `ld`); - } - const load_data = async (): Promise<LoadData | undefined> => { try { const location_gcss = await db.location_gcs_get({ @@ -41,17 +38,15 @@ location_gcss: location_gcss.results, } satisfies LoadData; } catch (e) { - console.log(`(error) load_data `, e); + await catch_err(e, `load_data`); } }; const handle_add_location_gcs = async (): Promise<void> => { try { console.log(`@todo`); - //const res = await location_gcs_add_current(); - //if (res) ld = await load_data(); } catch (e) { - console.log(`(error) handle_add_location_gcs `, e); + await catch_err(e, `handle_add_location_gcs`); } }; </script> diff --git a/src/routes/(app)/models/nostr-profile/+page.svelte b/src/routes/(app)/models/nostr-profile/+page.svelte @@ -5,6 +5,7 @@ app_nostr_key, app_notify, ascii, + catch_err, Glyph, type ISelectOption, LayoutTrellis, @@ -64,10 +65,6 @@ } }); - $: { - console.log(JSON.stringify(ld, null, 4), `ld`); - } - const load_data = async (): Promise<LoadData | undefined> => { try { const nostr_profiles = await db.nostr_profile_get({ @@ -81,22 +78,19 @@ app_notify.set(`${$ls(`error.client.page.load`)}`); return; } - const data: LoadData = { + return { nostr_profiles: nostr_profiles.results, - }; - return data; + } satisfies LoadData; } catch (e) { - console.log(`(error) load_data `, e); + await catch_err(e, `load_data`); } }; const handle_add_location_gcs = async (): Promise<void> => { try { console.log(`@todo`); - //const res = await location_gcs_add_current(); - //if (res) ld = await load_data(); } catch (e) { - console.log(`(error) handle_add_location_gcs `, e); + await catch_err(e, `handle_add_location_gcs`); } }; @@ -105,7 +99,7 @@ const ks_keys = await keystore.entries(); console.log(JSON.stringify(ks_keys, null, 4), `ks_keys`); } catch (e) { - console.log(`(error) handle_add_nostr_profile `, e); + await catch_err(e, `handle_add_nostr_profile`); } }; @@ -113,32 +107,36 @@ option: string; public_key: string; }): Promise<void> => { - switch (opts.option) { - case `view-key`: - case `add-profile-name`: - case `edit-profile-name`: { - $nav_prev.push({ - route: `/models/nostr-profile/view`, - label: `Keys`, - }); - } - - case `view-key`: - { - await route(`/models/nostr-profile/view`, [ - [`nostr_pk`, opts.public_key], - ]); - } - break; - case `add-profile-name`: - case `edit-profile-name`: - { - await route(`/models/nostr-profile/edit/field`, [ - [`nostr_pk`, opts.public_key], - [`rkey`, `name`], - ]); + try { + switch (opts.option) { + case `view-key`: + case `add-profile-name`: + case `edit-profile-name`: { + $nav_prev.push({ + route: `/models/nostr-profile/view`, + label: `Keys`, + }); } - break; + + case `view-key`: + { + await route(`/models/nostr-profile/view`, [ + [`nostr_pk`, opts.public_key], + ]); + } + break; + case `add-profile-name`: + case `edit-profile-name`: + { + await route(`/models/nostr-profile/edit/field`, [ + [`nostr_pk`, opts.public_key], + [`rkey`, `name`], + ]); + } + break; + } + } catch (e) { + await catch_err(e, `handle_key_options_press`); } }; </script> diff --git a/src/routes/(app)/models/nostr-profile/edit/field/+page.svelte b/src/routes/(app)/models/nostr-profile/edit/field/+page.svelte @@ -9,6 +9,7 @@ } from "@radroots/models"; import { app_notify, + catch_err, Fill, fmt_id, kv, @@ -67,6 +68,7 @@ $: if (el_input_loaded && el_input) { el_input.focus(); } + const load_page = async (): Promise<LoadData | undefined> => { try { const nostr_profiles = await db.nostr_profile_get({ @@ -83,20 +85,17 @@ ); return; } - const field_key = parse_nostr_profile_form_keys($qp_rkey); if (!field_key) { app_notify.set(`${$ls(`error.client.page.load`)}`); return; } - - const data: LoadData = { + return { nostr_profile: nostr_profiles.results[0], field_key, - }; - return data; + } satisfies LoadData; } catch (e) { - console.log(`(error) load_page `, e); + await catch_err(e, `load_page`); } }; @@ -138,9 +137,8 @@ [`id`, ld.nostr_profile.id], ]); else await route_prev(`/models/nostr-profile`); - return; } catch (e) { - console.log(`(error) submit `, e); + await catch_err(e, `submit`); } }; </script> diff --git a/src/routes/(app)/models/nostr-profile/view/+page.svelte b/src/routes/(app)/models/nostr-profile/view/+page.svelte @@ -7,6 +7,7 @@ app_notify, app_submit_route, as_glyph_key, + catch_err, clipboard_copy, LayoutTrellis, LayoutView, @@ -49,10 +50,6 @@ const nostr_profiles = await db.nostr_profile_get({ public_key: $qp_nostr_pk, }); - console.log( - JSON.stringify(nostr_profiles, null, 4), - `nostr_profiles`, - ); if (`err` in nostr_profiles) { app_notify.set(`${$ls(`error.client.page.load`)}`); return; @@ -60,7 +57,6 @@ app_notify.set(`${$ls(`error.client.page.load`)}`); return; } - const ks_secret_key = await keystore.get( ks.keys.nostr_secretkey($qp_nostr_pk), ); @@ -68,18 +64,15 @@ app_notify.set(`Error loading profile`); return; } - const nostr_relays = await db.nostr_relay_get({ list: [`on_profile`, { public_key: $qp_nostr_pk }], sort: `oldest`, }); - const nostr_relays_unconnected = await db.nostr_relay_get({ list: [`off_profile`, { public_key: $qp_nostr_pk }], sort: `oldest`, }); - - const data: LoadData = { + return { nostr_profile: nostr_profiles.results[0], secret_key: ks_secret_key.result, nostr_relays: @@ -88,17 +81,12 @@ `results` in nostr_relays_unconnected ? nostr_relays_unconnected.results : [], - }; - return data; + } satisfies LoadData; } catch (e) { - console.log(`(error) load_data `, e); + await catch_err(e, `load_data`); } }; - $: { - console.log(JSON.stringify(ld, null, 4), `ld`); - } - let tr_nostr_relays: ITrellisKindTouch[] = []; $: tr_nostr_relays = ld?.nostr_profile && ld?.nostr_relays.length diff --git a/src/routes/(app)/models/nostr-relay/+page.svelte b/src/routes/(app)/models/nostr-relay/+page.svelte @@ -4,6 +4,7 @@ import { app_nostr_key, app_notify, + catch_err, GlyphCircle, LayoutTrellis, LayoutView, @@ -44,7 +45,6 @@ app_notify.set(`${$ls(`error.client.page.load`)}`); return; } - const nostr_relays_other = await db.nostr_relay_get({ list: [`off_profile`, { public_key: $app_nostr_key }], sort: `oldest`, @@ -53,14 +53,12 @@ app_notify.set(`${$ls(`error.client.page.load`)}`); return; } - - const data: LoadData = { + return { nostr_relays: nostr_relays.results, nostr_relays_other: nostr_relays_other.results, - }; - return data; + } satisfies LoadData; } catch (e) { - console.log(`(error) load_data `, e); + await catch_err(e, `load_data`); } }; @@ -152,7 +150,7 @@ alert(`@todo`); } catch (e) { - console.log(`(error) handle_disconnect_relay `, e); + await catch_err(e, `handle_disconnect_relay`); } finally { loading_edit_id = ``; show_edit = false; diff --git a/src/routes/(app)/models/nostr-relay/view/+page.svelte b/src/routes/(app)/models/nostr-relay/view/+page.svelte @@ -4,6 +4,7 @@ import { app_blur, app_notify, + catch_err, EnvelopeButtons, LayoutTrellis, LayoutView, @@ -44,18 +45,14 @@ app_notify.set(`${$ls(`error.client.page.load`)}`); return; } - const nostr_relay = nostr_relays.results[0]; - const nostr_profiles = await db.nostr_profile_get({ list: [`on_relay`, { id: nostr_relay.id }], }); - const nostr_profiles_unconnected = await db.nostr_profile_get({ list: [`off_relay`, { id: nostr_relay.id }], }); - - const data: LoadData = { + return { nostr_relay, nostr_profiles: `results` in nostr_profiles ? nostr_profiles.results : [], @@ -63,29 +60,25 @@ `results` in nostr_profiles_unconnected ? nostr_profiles_unconnected.results : [], - }; - return data; + } satisfies LoadData; } catch (e) { - console.log(`(error) load_data `, e); + await catch_err(e, `load_data`); } }; $: app_blur.set(show_edit); - $: { - console.log(JSON.stringify(ld, null, 4), `ld`); - } const relay_connect = async (): Promise<void> => { try { } catch (e) { - console.log(`(error) relay_connect `, e); + await catch_err(e, `relay_connect`); } }; const relay_disconnect = async (): Promise<void> => { try { } catch (e) { - console.log(`(error) relay_disconnect `, e); + await catch_err(e, `relay_disconnect`); } }; </script> diff --git a/src/routes/(app)/models/trade-product/+page.svelte b/src/routes/(app)/models/trade-product/+page.svelte @@ -4,6 +4,7 @@ import type { TradeProductBundle } from "$lib/types"; import { app_notify, + catch_err, LayoutTrellis, LayoutView, ls, @@ -36,7 +37,6 @@ ); return; } - const results: TradeProductBundle[] = []; for (const trade_product of trade_products.results) { const location_gcs_res = await db.location_gcs_get({ @@ -50,7 +50,6 @@ const media_uploads_res = await db.media_upload_get({ list: [`on_trade_product`, { id: trade_product.id }], }); - results.push({ trade_product, location_gcs, @@ -60,19 +59,13 @@ : undefined, }); } - - const data: LoadData = { + return { results, - }; - return data; + } satisfies LoadData; } catch (e) { - console.log(`(error) load_data `, e); + await catch_err(e, `load_data`); } }; - - $: { - console.log(JSON.stringify(ld, null, 4), `ld`); - } </script> {#if ld && ld.results.length > 0} diff --git a/src/routes/(app)/models/trade-product/add/+page.svelte b/src/routes/(app)/models/trade-product/add/+page.svelte @@ -28,6 +28,7 @@ carousel_index, carousel_index_max, carousel_num, + catch_err, el_id, EntryLine, EntryMultiline, @@ -194,7 +195,7 @@ if (`results` in location_gcs_get_ls) tradepr_lgc_list = location_gcs_get_ls.results; } catch (e) { - console.log(`(error) init_page `, e); + await catch_err(e, `init_page`); } }; @@ -213,7 +214,7 @@ ], ]); } catch (e) { - console.log(`(error) setup_tests `, e); + await catch_err(e, `setup_tests`); } }; @@ -282,7 +283,7 @@ carousel_index.set(0); view = view_new; } catch (e) { - console.log(`(error) handle_view `, e); + await catch_err(e, `handle_view`); } }; @@ -300,7 +301,7 @@ tradepr_key_sel_toggle = vis_input; if (vis_input) tradepr_key_sel = ``; } catch (e) { - console.log(`(error) handle_tradepr_key_toggle `, e); + await catch_err(e, `handle_tradepr_key_toggle`); } }; @@ -318,7 +319,7 @@ tradepr_process_sel_toggle = vis_input; if (vis_input) tradepr_process_sel = ``; } catch (e) { - console.log(`(error) handle_tradepr_process_toggle `, e); + await catch_err(e, `handle_tradepr_process_toggle`); } }; @@ -341,7 +342,7 @@ } tradepr_qty_tup_sel_toggle = vis_input; } catch (e) { - console.log(`(error) handle_tradepr_qty_amt_toggle `, e); + await catch_err(e, `handle_tradepr_qty_amt_toggle`); } }; @@ -360,7 +361,7 @@ lng: geolc.lng, }; } catch (e) { - console.log(`(error) handle_tradepr_lgc_sel_map `, e); + await catch_err(e, `handle_tradepr_lgc_sel_map`); } }; @@ -384,7 +385,7 @@ carousel_index.set(Math.max($carousel_index - (num - 1), 0)); } } catch (e) { - console.log(`(error) handle_back `, e); + await catch_err(e, `handle_back`); } }; @@ -435,7 +436,7 @@ break; } } catch (e) { - console.log(`(error) handle_continue `, e); + await catch_err(e, `handle_continue`); } }; @@ -470,6 +471,7 @@ await model_location_gcs_add_geocode({ geo_code: tradepr_lgc_map_geoc, point: tradepr_lgc_map_point, + kind: `trade_product`, }); if ( `err` in location_gcs_add_geocode || @@ -653,7 +655,7 @@ await sleep(2000); await route(`/`); } catch (e) { - console.log(`(error) submit `, e); + await catch_err(e, `submit`); } finally { load_submit = false; } diff --git a/src/routes/(app)/models/trade-product/view/+page.svelte b/src/routes/(app)/models/trade-product/view/+page.svelte @@ -3,6 +3,7 @@ import type { TradeProductBundle } from "$lib/types"; import { app_notify, + catch_err, LayoutTrellis, LayoutView, ls, @@ -33,23 +34,19 @@ return; } const { result: trade_product } = _trade_product; - const location_gcs_res = await db.location_gcs_get({ list: [`on_trade_product`, { id: trade_product.id }], }); if (`err` in location_gcs_res) { - //@todo - return; + return; //@todo } const location_gcs = location_gcs_res.results[0]; - - const data: LoadData = { + return { trade_product, location_gcs, - }; - return data; + } satisfies LoadData; } catch (e) { - console.log(`(error) load_data `, e); + await catch_err(e, `load_data`); } }; </script> diff --git a/src/routes/(app)/settings/nostr/+page.svelte b/src/routes/(app)/settings/nostr/+page.svelte @@ -6,6 +6,7 @@ Nav, Trellis, ascii, + catch_err, ls, type ISelectOption, } from "@radroots/svelte-lib"; @@ -50,7 +51,7 @@ try { nostr_photohosting_sel_val = `^radroots`; //@todo } catch (e) { - console.log(`(error) init_page `, e); + await catch_err(e, `init_page`); } }; @@ -73,7 +74,7 @@ await dialog.alert(`@todo`); //@todo nostr_photohosting_sel_val = `^radroots`; } catch (e) { - console.log(`(error) handle_select_option `, e); + await catch_err(e, `handle_select_option`); } }; </script> diff --git a/src/routes/(app)/settings/profile/+page.svelte b/src/routes/(app)/settings/profile/+page.svelte @@ -1,6 +1,7 @@ <script lang="ts"> import { db, dialog, fs } from "$lib/client"; import ImageUploadAddPhoto from "$lib/components/image_upload_add_photo.svelte"; + import { throw_err } from "$lib/util/error"; import { kv_init_page } from "$lib/util/kv"; import { model_media_upload_add_list } from "$lib/util/models-media-upload"; import { nostr_sync_metadata } from "$lib/util/nostr-sync"; @@ -8,6 +9,7 @@ import { app_nostr_key, ascii, + catch_err, Glyph, ImageBlob, ImagePath, @@ -36,6 +38,7 @@ try { await init_page(); } catch (e) { + await catch_err(e, `mount`); } finally { } }); @@ -44,6 +47,7 @@ try { await nostr_sync_metadata(); } catch (e) { + await catch_err(e, `destroy`); } finally { } }); @@ -64,21 +68,22 @@ await kv_init_page(); ld = await load_data(); } catch (e) { - console.log(`(error) init_page `, e); + await catch_err(e, `init_page`); } }; const load_data = async (): Promise<LoadData | undefined> => { try { let nostr_profile_get_one = await db.nostr_profile_get_one({ - public_key: $app_nostr_key, + public_key: $app_nostr_key + `ye`, }); - if (`err` in nostr_profile_get_one) return; + if (`err` in nostr_profile_get_one) + return throw_err(nostr_profile_get_one); return { nostr_profile: nostr_profile_get_one.result, } satisfies LoadData; } catch (e) { - console.log(`(error) load_data `, e); + await catch_err(e, `load_data`); } }; @@ -87,7 +92,7 @@ if (opt_photo_path) await handle_profile_photo_add(opt_photo_path); await route(`/`); } catch (e) { - console.log(`(error) handle_back `, e); + await catch_err(e, `handle_back`); } }; @@ -144,11 +149,50 @@ } location.reload(); } catch (e) { - console.log(`(error) handle_profile_photo_add `, e); + await catch_err(e, `handle_profile_photo_add`); } finally { loading_photo_upload = false; } }; + + const handle_edit_display_name = async (): Promise<void> => { + try { + await route(`/settings/profile/edit`, [ + [`nostr_pk`, $app_nostr_key], + [`rkey`, `display_name`], + ]); + } catch (e) { + await catch_err(e, `handle_edit_display_name`); + } + }; + + const handle_edit_name = async (): Promise<void> => { + try { + if (ld?.nostr_profile.name) { + const confirm = await dialog.confirm({ + message: `Updating your username will result in public links on your profile being updated. Do you want to continue?`, + }); + if (!confirm) return; + } + await route(`/settings/profile/edit`, [ + [`nostr_pk`, $app_nostr_key], + [`rkey`, `name`], + ]); + } catch (e) { + await catch_err(e, `handle_edit_name`); + } + }; + + const handle_edit_about = async (): Promise<void> => { + try { + await route(`/settings/profile/edit`, [ + [`nostr_pk`, $app_nostr_key], + [`rkey`, `about`], + ]); + } catch (e) { + await catch_err(e, `handle_edit_about`); + } + }; </script> <div @@ -221,10 +265,7 @@ <button class={`group flex flex-row justify-center items-center`} on:click={async () => { - await route(`/settings/profile/edit`, [ - [`nostr_pk`, $app_nostr_key], - [`rkey`, `display_name`], - ]); + await handle_edit_display_name(); }} > <p @@ -242,14 +283,7 @@ <button class={`group flex flex-row justify-center items-center`} on:click={async () => { - const confirm = await dialog.confirm({ - message: `Updating your username will result in public links on your profile being updated. Do you want to continue?`, - }); - if (confirm) - await route(`/settings/profile/edit`, [ - [`nostr_pk`, $app_nostr_key], - [`rkey`, `name`], - ]); + await handle_edit_name(); }} > <p @@ -285,10 +319,7 @@ <button class={`group flex flex-row justify-center items-center`} on:click={async () => { - await route(`/settings/profile/edit`, [ - [`nostr_pk`, $app_nostr_key], - [`rkey`, `about`], - ]); + await handle_edit_about(); }} > <p diff --git a/src/routes/(app)/settings/profile/edit/+page.svelte b/src/routes/(app)/settings/profile/edit/+page.svelte @@ -10,6 +10,7 @@ } from "@radroots/models"; import { app_notify, + catch_err, fmt_id, InputElement, kv, @@ -34,6 +35,8 @@ onMount(async () => { try { + console.log(`$qp_rkey `, $qp_rkey); + console.log(`$qp_nostr_pk `, $qp_nostr_pk); if (!$qp_rkey || !$qp_nostr_pk) { app_notify.set( `${$ls(`icu.error_loading_*`, { value: `${$ls(`common.page`)}` })}`, @@ -58,6 +61,7 @@ ? `${$ls(`models.nostr_profile.fields.${ld.field_key}.label`)}` : ``; $: input_value_del = page_initial_value !== page_input_value; + const load_page = async (): Promise<LoadData | undefined> => { try { const nostr_profile = await db.nostr_profile_get_one({ @@ -69,26 +73,22 @@ ); return; } - const field_key = parse_nostr_profile_form_keys($qp_rkey); if (!field_key) { app_notify.set(`${$ls(`error.client.page.load`)}`); return; } - const field_val = nostr_profile.result[field_key]; if (field_val) { page_input_value = field_val; page_initial_value = field_val; } - - const data: LoadData = { + return { nostr_profile: nostr_profile.result, field_key, - }; - return data; + } satisfies LoadData; } catch (e) { - console.log(`(error) load_page `, e); + await catch_err(e, `load_page`); } }; @@ -122,7 +122,7 @@ } await route(`/settings/profile`); } catch (e) { - console.log(`(error) submit `, e); + await catch_err(e, `submit`); } }; </script> diff --git a/src/routes/(cfg)/cfg/+layout.ts b/src/routes/(cfg)/cfg/+layout.ts @@ -1,13 +1,11 @@ import { keystore } from '$lib/client'; import { ks } from '$lib/conf'; -import { app_splash, route } from '@radroots/svelte-lib'; +import { app_splash, catch_err, route } from '@radroots/svelte-lib'; import type { LayoutLoad, LayoutLoadEvent } from './$types'; -export const load: LayoutLoad = async ({ url }: LayoutLoadEvent) => { +export const load: LayoutLoad = async (_: LayoutLoadEvent) => { try { await keystore.init(); - - console.log(`(cfg) `, url.pathname) const ks_nostr_publickey = await keystore.get( ks.keys.nostr_publickey, ); @@ -22,9 +20,8 @@ export const load: LayoutLoad = async ({ url }: LayoutLoadEvent) => { } app_splash.set(false); } catch (e) { - console.log(`(cfg) ERROR`, e) + await catch_err(e, `(cfg)load`) } finally { - //await win.splash_hide(); return {}; }; }; diff --git a/src/routes/(cfg)/cfg/init/+page.svelte b/src/routes/(cfg)/cfg/init/+page.svelte @@ -20,6 +20,7 @@ carousel_inc, carousel_index, carousel_index_max, + catch_err, DisplayLine, el_id, EntryLine, @@ -124,7 +125,7 @@ await lookup_ks(); await kv_init_page(); } catch (e) { - console.log(`(error) init_page `, e); + await catch_err(e, `init_page`); } }; @@ -164,7 +165,6 @@ cancel_label: `${$ls(`common.reset`)}`, ok_label: `${$ls(`common.yes`)}`, }); - if (confirm === false) { await keystore.remove(ks.cfg_init.nostr_secretkey); await keystore.remove(ks.cfg_init.radroots_tok); @@ -191,7 +191,7 @@ } } } catch (e) { - console.log(`(error) lookup_ks `, e); + await catch_err(e, `lookup_ks`); } finally { app_loading.set(false); } @@ -204,7 +204,7 @@ if (alert_message) await dialog.alert(alert_message); await sleep(cfg.delay.load); } catch (e) { - console.log(`(error) reset `, e); + await catch_err(e, `reset_page`); } finally { app_loading.set(false); } @@ -220,7 +220,7 @@ await keystore.remove(ks_key); } } catch (e) { - console.log(`(error) reset_ks `, e); + await catch_err(e, `reset_ks`); } }; @@ -271,7 +271,7 @@ } } } catch (e) { - console.log(`(error) handle_back `, e); + await catch_err(e, `handle_back`); } }; @@ -435,14 +435,13 @@ break; } } catch (e) { - console.log(`(error) handle_continue `, e); + await catch_err(e, `handle_continue`); } }; const submit = async (): Promise<void> => { try { loading_submit = true; - const ks_nostr_secretkey = await keystore.get( ks.cfg_init.nostr_secretkey, ); @@ -478,7 +477,6 @@ ); return; //@todo } - const nostr_profile_add = await db.nostr_profile_add({ public_key: nostr_publickey, name: @@ -486,7 +484,6 @@ ? ks_nostr_profilename.result : undefined, }); - if (`err` in nostr_profile_add || `err_s` in nostr_profile_add) { await dialog.alert( `${$ls(`icu.failure_saving_*_to_the_database`, { value: `${$ls(`common.profile`)}`.toLowerCase() })}`, @@ -523,7 +520,7 @@ notify_message: `${$ls(`app.cfg.init.notification.welcome`)}`, }); } catch (e) { - console.log(`(error) submit `, e); + await catch_err(e, `submit`); } finally { loading_submit = false; } diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte @@ -14,6 +14,7 @@ app_splash, app_th, app_thc, + catch_err, Controls, CssStatic, CssStyles, @@ -51,14 +52,14 @@ } }); - app_thc.subscribe((app_thc) => { - const color_mode = parse_color_mode(app_thc); + app_thc.subscribe((_app_thc) => { + const color_mode = parse_color_mode(_app_thc); theme_set(parse_theme_key($app_th), color_mode); }); - app_th.subscribe((app_th) => { + app_th.subscribe((_app_th) => { const color_mode = parse_color_mode($app_thc); - theme_set(parse_theme_key(app_th), color_mode); + theme_set(parse_theme_key(_app_th), color_mode); }); app_db.subscribe((_app_db) => { @@ -95,7 +96,7 @@ log_unlisten = await logger.init(); await kv_init_app(); } catch (e) { - console.log(`(error) init_app `, e); + await catch_err(e, `init_app`); } }; </script> diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts @@ -1,4 +1,4 @@ -import { default_locale, load_translations, locales, translations_loading } from '@radroots/svelte-lib'; +import { catch_err, default_locale, load_translations, locales, translations_loading } from '@radroots/svelte-lib'; import type { LayoutLoad, LayoutLoadEvent } from './$types'; export const prerender = true; @@ -7,7 +7,6 @@ export const trailingSlash = 'always'; export const load: LayoutLoad = async ({ url }: LayoutLoadEvent) => { try { - console.log(`(root) `, url.pathname) const { language: nav_locale } = navigator; let locale = default_locale.toString(); const locales_avail = locales.get(); @@ -16,7 +15,7 @@ export const load: LayoutLoad = async ({ url }: LayoutLoadEvent) => { await load_translations(locale.toLowerCase(), url.pathname); await translations_loading.toPromise(); } catch (e) { - console.log(`(load) ERROR`, e) + await catch_err(e, `(root)load`) } finally { return {}; }; diff --git a/tailwind.config.ts b/tailwind.config.ts @@ -188,6 +188,8 @@ const config: Config = { themes: [ themes.theme_os_dark, themes.theme_os_light, + themes.theme_garden_light, + themes.theme_garden_dark ], }, };