commit 0fc8fe45b02017de9c3e0a9ebd4f6f0dbf425f58
parent e5f5a513a721f9a6c785ea4cb04298d2bc2b8e67
Author: triesap <137732411+triesap@users.noreply.github.com>
Date: Thu, 24 Oct 2024 21:41:09 +0000
Edit `/models/nostr-profile` trellis styles. Edit reset device util.
Diffstat:
4 files changed, 159 insertions(+), 124 deletions(-)
diff --git a/src/lib/utils/client.ts b/src/lib/utils/client.ts
@@ -1,4 +1,4 @@
-import { keystore } from "$lib/client";
+import { db, keystore } from "$lib/client";
import { app_notify, route, type NavigationRoute } from "@radroots/svelte-lib";
import type { ErrorMessage } from "@radroots/utils";
@@ -27,11 +27,23 @@ export const restart = async (opts?: {
export const reset_device = async (): Promise<ErrorMessage<string> | undefined> => {
try {
+ // delete keystore keys
const ks_keys = await keystore.keys();
- console.log(JSON.stringify(ks_keys, null, 4), `ks_keys`)
if (`err` in ks_keys) return ks_keys;
for (const ks_key of ks_keys.results) await keystore.remove(ks_key);
- // @todo add database reset
+ // delete database tables
+ const location_gcss = await db.location_gcs_get({ list: [`all`] });
+ if (`err` in location_gcss) return location_gcss;
+ for (const { id } of location_gcss.results) await db.location_gcs_delete({ id });
+ const trade_products = await db.trade_product_get({ list: [`all`] });
+ if (`err` in trade_products) return trade_products;
+ for (const { id } of trade_products.results) await db.trade_product_delete({ id });
+ const nostr_profiles = await db.nostr_profile_get({ list: [`all`] });
+ if (`err` in nostr_profiles) return nostr_profiles;
+ for (const { id } of nostr_profiles.results) await db.nostr_profile_delete({ id });
+ const nostr_relays = await db.nostr_relay_get({ list: [`all`] });
+ if (`err` in nostr_relays) return nostr_relays;
+ for (const { id } of nostr_relays.results) await db.nostr_relay_delete({ id });
await route(`/`);
} catch (e) {
console.log(`(error) reset_device `, e);
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte
@@ -11,6 +11,7 @@
route,
t,
Tabs,
+ TrellisTitle,
type AppConfigType,
type CallbackPromise,
type GlyphKey,
@@ -98,7 +99,7 @@
</p>
</button>
</div>
- <div class={`flex flex-col justify-center items-center`}>
+ <div class={`flex flex-col pt-2 justify-center items-center`}>
{#if tmp_show_no_profile}
<button
class={`relative flex flex-row h-24 w-${$app_layout} p-4 gap-4 justify-center items-center bg-layer-2-surface/60 rounded-touch touch-layer-1 touch-layer-1-raise-less el-re`}
@@ -141,13 +142,15 @@
</button>
{/if}
</div>
- <div class={`flex flex-col w-full gap-2 justify-start items-center`}>
- <div class={`flex flex-row w-full px-8 justify-start items-center`}>
- <p class={`font-sans font-[500] text-layer-0-glyph capitalize`}>
- {`${$t(`common.options_list`)}:`}
- </p>
+ <div class={`flex flex-col w-full gap-[2px] justify-start items-center`}>
+ <div class={`flex flex-row w-full px-6 justify-center items-center`}>
+ <TrellisTitle
+ basis={{
+ value: `${$t(`common.options`)}`,
+ }}
+ />
</div>
- <div class={`flex flex-col w-full gap-4 justify-start items-center`}>
+ <div class={`flex flex-col w-full gap-5 justify-start items-center`}>
{#each page_param.buttons[$app_cfg_type] as btn}
<button
class={`flex flex-row h-20 w-${$app_layout} py-2 px-6 justify-between items-center rounded-touch bg-layer-1-surface touch-layer-1 touch-layer-1-raise-less el-re`}
@@ -198,12 +201,19 @@
label: `Home`,
callback: async () => {
await route(`/`);
+ const res = await db.nostr_relay_get({ list: [`all`] });
+ console.log(JSON.stringify(res, null, 4), `res`);
},
},
{
icon: `arrows-down-up`,
label: `Transactions`,
- callback: async () => {},
+ callback: async () => {
+ const res = await db.nostr_relay_get({
+ list: [`on_profile`, { public_key: $app_nostr_key }],
+ });
+ console.log(JSON.stringify(res, null, 4), `res`);
+ },
},
{
icon: `cardholder`,
diff --git a/src/routes/(app)/models/nostr-profile/+page.svelte b/src/routes/(app)/models/nostr-profile/+page.svelte
@@ -156,131 +156,139 @@
}}
/>
{#if ld.nostr_profiles.length}
- {#each ld.nostr_profiles as li (li.public_key)}
- <div
- class={`relative flex flex-col h-24 pt-5 px-3 bg-layer-1-surface rounded-touch overflow-hidden active:ring-4 active:ring-layer-2-surface/80 transition-all tap-rise-1 active:opacity-60`}
- >
- <button
- class={`flex flex-col h-full w-full pt-[2px] pl-1 gap-1 items-start`}
- on:click|preventDefault={async () => {
- $nav_prev.push({
- route: `/models/nostr-profile`,
- label: `${$t(`common.profiles`)}`,
- });
- await route(`/models/nostr-profile/view`, [
- [`nostr_pk`, li.public_key],
- ]);
- }}
+ <div
+ class={`flex flex-col w-full gap-4 justify-center items-center`}
+ >
+ {#each ld.nostr_profiles as li (li.public_key)}
+ <div
+ class={`relative flex flex-col h-24 pt-5 px-3 bg-layer-1-surface rounded-touch overflow-hidden active:ring-4 active:ring-layer-2-surface/80 transition-all tap-rise-1 active:opacity-60`}
>
- <div
- class={`flex flex-row w-full pl-1 gap-4 justify-start items-center`}
+ <button
+ class={`flex flex-col h-full w-full pt-[2px] pl-1 gap-1 items-start`}
+ on:click|preventDefault={async () => {
+ $nav_prev.push({
+ route: `/models/nostr-profile`,
+ label: `${$t(`common.profiles`)}`,
+ });
+ await route(
+ `/models/nostr-profile/view`,
+ [[`nostr_pk`, li.public_key]],
+ );
+ }}
>
- <p
- class={`font-mono text-[1.1rem] text-layer-1-glyph-shade text-ellipsis overflow-hidden`}
+ <div
+ class={`flex flex-row w-full pl-1 gap-4 justify-start items-center`}
>
- {li.name
- ? li.name
- : `(${`${$t(`icu.no_*`, { value: `${$t(`common.profile`)}` })}`})`}
- </p>
- {#if li.public_key === $app_nostr_key}
- <div class={`flex flex-row`}>
+ <p
+ class={`font-mono text-[1.1rem] text-layer-1-glyph-shade text-ellipsis overflow-hidden`}
+ >
+ {li.name
+ ? li.name
+ : `(${`${$t(`icu.no_*`, { value: `${$t(`common.profile`)}` })}`})`}
+ </p>
+ {#if li.public_key === $app_nostr_key}
+ <div class={`flex flex-row`}>
+ <div
+ class={`flex flex-row h-4 justify-center items-center px-[6px] bg-success/70 rounded-md -translate-y-[1px]`}
+ >
+ <p
+ class={`font-mono font-[900] text-[0.7rem] text-white text-ellipsis overflow-hidden`}
+ >
+ {`${$t(`common.active`)}`}
+ </p>
+ </div>
+ </div>
+ {/if}
+ </div>
+ <div
+ class={`grid grid-cols-12 flex flex-row h-6 w-full pt-2 gap-2 items-center`}
+ >
+ <div
+ class={`col-span-2 flex flex-row h-full items-center `}
+ >
<div
- class={`flex flex-row h-4 justify-center items-center px-[6px] bg-success/70 rounded-md -translate-y-[1px]`}
+ class={`flex flex-row h-[1rem] px-[9px] justify-start items-center bg-zinc-800/90 rounded-[5px] translate-y-[1px]`}
>
<p
- class={`font-mono font-[900] text-[0.7rem] text-white text-ellipsis overflow-hidden`}
+ class={`font-mono font-[600] text-[0.9rem] text-layer-2-glyph lowercase line-clamp-1`}
>
- {`${$t(`common.active`)}`}
+ {`${$t(`common.key`)}`}
</p>
</div>
</div>
- {/if}
- </div>
- <div
- class={`grid grid-cols-12 flex flex-row h-6 w-full pt-2 gap-2 items-center`}
- >
- <div
- class={`col-span-2 flex flex-row h-full items-center `}
- >
<div
- class={`flex flex-row h-[1rem] px-[9px] justify-start items-center bg-zinc-800/90 rounded-[5px] translate-y-[1px]`}
+ class={`col-span-10 flex flex-row h-full pr-2 justify-end items-center overflow-x-hidden`}
>
<p
- class={`font-mono font-[600] text-[0.9rem] text-layer-2-glyph lowercase line-clamp-1`}
+ class={`font-mono text-[0.9rem] text-layer-1-glyph line-clamp-1`}
>
- {`${$t(`common.key`)}`}
+ {`${`${nostr.lib.npub(li.public_key) || ""}`.slice(
+ 0,
+ 24,
+ )}...`}
</p>
</div>
</div>
- <div
- class={`col-span-10 flex flex-row h-full pr-2 justify-end items-center overflow-x-hidden`}
+ </button>
+ <div
+ class={`z-10 absolute top-2 right-3 flex flex-row h-full justify-end pr-1`}
+ >
+ <SelectElement
+ basis={{
+ args: {
+ layer: 0,
+ mask: true,
+ callback: async ({ value }) => {
+ await handle_key_options_press(
+ {
+ option: value,
+ public_key:
+ li.public_key,
+ },
+ );
+ },
+ options: [
+ {
+ entries:
+ page_param.options_list.filter(
+ (i) =>
+ !(
+ !li.name &&
+ i.value ===
+ `edit-profile-name`
+ ) &&
+ !(
+ li.name &&
+ i.value ===
+ `add-profile-name`
+ ) &&
+ !(
+ li.public_key ===
+ $app_nostr_key &&
+ i.value ===
+ `set-key-active`
+ ),
+ ),
+ },
+ ],
+ },
+ }}
>
- <p
- class={`font-mono text-[0.9rem] text-layer-1-glyph line-clamp-1`}
- >
- {`${`${nostr.lib.npub(li.public_key) || ""}`.slice(
- 0,
- 24,
- )}...`}
- </p>
- </div>
+ <svelte:fragment slot="element">
+ <Glyph
+ basis={{
+ key: `dots-three`,
+ dim: `md`,
+ classes: `text-layer-1-glyph`,
+ weight: `bold`,
+ }}
+ />
+ </svelte:fragment>
+ </SelectElement>
</div>
- </button>
- <div
- class={`z-10 absolute top-2 right-3 flex flex-row h-full justify-end pr-1`}
- >
- <SelectElement
- basis={{
- args: {
- layer: 0,
- mask: true,
- callback: async ({ value }) => {
- await handle_key_options_press({
- option: value,
- public_key: li.public_key,
- });
- },
- options: [
- {
- entries:
- page_param.options_list.filter(
- (i) =>
- !(
- !li.name &&
- i.value ===
- `edit-profile-name`
- ) &&
- !(
- li.name &&
- i.value ===
- `add-profile-name`
- ) &&
- !(
- li.public_key ===
- $app_nostr_key &&
- i.value ===
- `set-key-active`
- ),
- ),
- },
- ],
- },
- }}
- >
- <svelte:fragment slot="element">
- <Glyph
- basis={{
- key: `dots-three`,
- dim: `md`,
- classes: `text-layer-1-glyph`,
- weight: `bold`,
- }}
- />
- </svelte:fragment>
- </SelectElement>
</div>
- </div>
- {/each}
+ {/each}
+ </div>
{/if}
</div>
</LayoutTrellis>
diff --git a/src/routes/(cfg)/cfg/init/+page.svelte b/src/routes/(cfg)/cfg/init/+page.svelte
@@ -645,14 +645,19 @@
);
return; // @todo
}
- await db.set_nostr_profile_relay({
- nostr_profile: {
- id: nostr_profile_add.id,
- },
- nostr_relay: {
- id: nostr_relay_add.id,
- },
- });
+ const nostr_profile_relay_add =
+ await db.set_nostr_profile_relay({
+ nostr_profile: {
+ id: nostr_profile_add.id,
+ },
+ nostr_relay: {
+ id: nostr_relay_add.id,
+ },
+ });
+ console.log(
+ JSON.stringify(nostr_profile_relay_add, null, 4),
+ `nostr_profile_relay_add`,
+ );
}
await reset_ks();
await restart({