diff --git a/.env.example b/packages/svelte/.env.example
similarity index 100%
rename from .env.example
rename to packages/svelte/.env.example
diff --git a/packages/svelte/gun.config.js b/packages/svelte/gun.config.js
deleted file mode 100644
index bc58039..0000000
--- a/packages/svelte/gun.config.js
+++ /dev/null
@@ -1,7 +0,0 @@
-//export const peers = ["https://gun-relay.scobrudot.dev/gun"];
-import env from "dotenv";
-
-env.config();
-
-export const peers = ["https://peer.wallie.io/gun"];
-export const validToken = process.env.VALID_TOKEN;
diff --git a/packages/svelte/gun.config.ts b/packages/svelte/gun.config.ts
new file mode 100644
index 0000000..77ef733
--- /dev/null
+++ b/packages/svelte/gun.config.ts
@@ -0,0 +1,9 @@
+export const peers = ["https://gun-relay.scobrudot.dev/gun", "https://peer.wallie.io/gun"];
+
+import env from "dotenv";
+
+const { VALID_TOKEN } = env as {
+ VALID_TOKEN?: string;
+};
+
+export const validToken = VALID_TOKEN;
diff --git a/packages/svelte/package.json b/packages/svelte/package.json
index 63d80c7..8944559 100644
--- a/packages/svelte/package.json
+++ b/packages/svelte/package.json
@@ -70,7 +70,7 @@
"express-rate-limit": "^7.4.0",
"gun": "^0.2020.1240",
"gun-avatar": "^1.9.4",
- "gun-eth": "^1.2.13",
+ "gun-eth": "^1.2.14",
"ip": "^2.0.1",
"js-sha256": "^0.11.0",
"js-sha3": "^0.9.3",
diff --git a/packages/svelte/src/lib/components/gun/account/AccountAvatar.svelte b/packages/svelte/src/lib/components/gun/account/AccountAvatar.svelte
index fbabee2..6dc4fa7 100644
--- a/packages/svelte/src/lib/components/gun/account/AccountAvatar.svelte
+++ b/packages/svelte/src/lib/components/gun/account/AccountAvatar.svelte
@@ -2,51 +2,55 @@
import { useAvatar } from '$lib/gun/avatar';
import { useUser } from '$lib/gun/user';
import { onMount, createEventDispatcher } from 'svelte';
-
const dispatch = createEventDispatcher();
const { user } = useUser();
- export let pub: string | undefined = undefined;
export let size: number = 96;
export let border: number = 2;
- let isOwnAvatar = false;
let fileInput: HTMLInputElement;
let avatarLoaded = false;
- $: ({ avatar, blink, uploadAvatar, uploadStatus } = useAvatar(pub || $user?.pub, size));
+ let { avatar: avatarStore, blink, uploadAvatar, uploadStatus, updateAvatar } = useAvatar($user.pub, size);
+ $: console.log("Avatar nel componente:", $avatarStore);
onMount(() => {
- if (!pub && $user?.pub) {
- pub = $user.pub;
- }
- isOwnAvatar = $user.pub === pub;
- console.log("isOwnAvatar:", isOwnAvatar, "$user.pub:", $user.pub, "pub:", pub);
+ updateAvatar();
});
async function handleFileChange(event: Event) {
const file = (event.target as HTMLInputElement).files?.[0];
- if (file) await uploadAvatar(file);
+ if (file) {
+ await uploadAvatar(file);
+ updateAvatar();
+ }
}
function onAvatarLoad() {
avatarLoaded = true;
dispatch('load');
}
+
+ function onAvatarError() {
+ avatarLoaded = true;
+ updateAvatar();
+ dispatch('load');
+ }
- {#if pub || $user?.pub}
+ {#if $user.pub}
- {#if isOwnAvatar && avatarLoaded}
+ {#if avatarLoaded}
\ No newline at end of file
+
diff --git a/packages/svelte/src/lib/components/gun/account/AccountProfile.svelte b/packages/svelte/src/lib/components/gun/account/AccountProfile.svelte
index 1beaf89..93ea0cc 100644
--- a/packages/svelte/src/lib/components/gun/account/AccountProfile.svelte
+++ b/packages/svelte/src/lib/components/gun/account/AccountProfile.svelte
@@ -7,12 +7,22 @@
let pub : string | undefined ;
let { user } = useUser();
- let { account } = useAccount(pub || $user?.pub);
+ console.log("user pub", $user);
+ let { account } = useAccount($user?.pub);
$: globalAccount = $account;
-
$: lastPulse = globalAccount?.pulse;
+ onMount(() => {
+ if (!pub && $user?.pub) {
+ pub = $user.pub;
+ }
+ });
+
+ $: pub = $user?.pub;
+
+
+
if (globalAccount && globalAccount.pulse !== lastPulse) {
lastPulse = globalAccount.pulse;
@@ -42,7 +52,7 @@
Account Information
-
+
{#if globalAccount}
{#each accountFields as { key, label }}