diff --git a/src/lib/components/Navigation.svelte b/src/lib/components/Navigation.svelte
index e155c03..186a93f 100644
--- a/src/lib/components/Navigation.svelte
+++ b/src/lib/components/Navigation.svelte
@@ -31,7 +31,9 @@
Visualize
Getting Started
Events
- My Notes
+ {#if userState.signedIn}
+ My Notes
+ {/if}
About
Contact
diff --git a/src/lib/ndk.ts b/src/lib/ndk.ts
index 45e9097..92d2430 100644
--- a/src/lib/ndk.ts
+++ b/src/lib/ndk.ts
@@ -91,20 +91,8 @@ function clearPersistentRelaySet(): void {
}
}
-// Subscribe to userStore changes and update ndkSignedIn accordingly
-userStore.subscribe(async (userState) => {
- ndkSignedIn.set(userState.signedIn);
-
- // Refresh relay stores when user state changes
- const ndk = get(ndkInstance);
- if (ndk) {
- try {
- await refreshRelayStores(ndk);
- } catch (error) {
- console.warn('[NDK.ts] Failed to refresh relay stores on user state change:', error);
- }
- }
-});
+// AI-NOTE: userStore subscription moved to initNdk function to prevent initialization errors
+// The subscription will be set up after userStore is properly initialized
/**
* Custom authentication policy that handles NIP-42 authentication manually
@@ -655,6 +643,21 @@ export function initNdk(): NDK {
attemptConnection();
+ // AI-NOTE: Set up userStore subscription after NDK initialization to prevent initialization errors
+ userStore.subscribe(async (userState) => {
+ ndkSignedIn.set(userState.signedIn);
+
+ // Refresh relay stores when user state changes
+ const ndk = get(ndkInstance);
+ if (ndk) {
+ try {
+ await refreshRelayStores(ndk);
+ } catch (error) {
+ console.warn('[NDK.ts] Failed to refresh relay stores on user state change:', error);
+ }
+ }
+ });
+
return ndk;
}
diff --git a/src/routes/my-notes/+page.svelte b/src/routes/my-notes/+page.svelte
index 4841b4c..852d31e 100644
--- a/src/routes/my-notes/+page.svelte
+++ b/src/routes/my-notes/+page.svelte
@@ -1,5 +1,6 @@