diff --git a/dist/index.html b/dist/index.html index 35e5dd00..fb66ac2f 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ Markr - Nostr Bookmarks - + diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index dc498a9b..ec0c31f4 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,6 +1,6 @@ { "name": "markr", - "version": "0.1.0", + "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package-lock.json b/package-lock.json index dc63fde4..c8ec50b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,14 @@ { "name": "markr", - "version": "0.1.0", + "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "markr", - "version": "0.1.0", + "version": "0.0.1", "dependencies": { + "applesauce-accounts": "^3.1.0", "applesauce-core": "^3.1.0", "applesauce-react": "^3.1.0", "nostr-tools": "^2.4.0", diff --git a/package.json b/package.json index 19a3ea69..52c16f78 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0" }, "dependencies": { + "applesauce-accounts": "^3.1.0", "applesauce-core": "^3.1.0", "applesauce-react": "^3.1.0", "nostr-tools": "^2.4.0", diff --git a/src/App.tsx b/src/App.tsx index 6f0299b5..ec84058d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,51 +1,43 @@ import { useState, useEffect } from 'react' -import { EventStoreProvider } from 'applesauce-react' +import { EventStoreProvider, AccountsProvider } from 'applesauce-react' import { EventStore } from 'applesauce-core' +import { AccountManager } from 'applesauce-accounts' import Login from './components/Login' import Bookmarks from './components/Bookmarks' function App() { const [eventStore, setEventStore] = useState(null) + const [accountManager, setAccountManager] = useState(null) const [isAuthenticated, setIsAuthenticated] = useState(false) - const [userPublicKey, setUserPublicKey] = useState(null) - const [userProfile, setUserProfile] = useState<{name?: string, username?: string, nip05?: string} | null>(null) useEffect(() => { - // Initialize event store + // Initialize event store and account manager const store = new EventStore() + const accounts = new AccountManager() setEventStore(store) + setAccountManager(accounts) }, []) - if (!eventStore) { + if (!eventStore || !accountManager) { return
Loading...
} return ( -
-
-

Markr

-

A minimal nostr bookmark client

-
- - {!isAuthenticated ? ( - { - setIsAuthenticated(true) - setUserPublicKey(publicKey) - setUserProfile(profile) - }} /> - ) : ( - { - setIsAuthenticated(false) - setUserPublicKey(null) - setUserProfile(null) - }} - /> - )} -
+ +
+
+

Markr

+

A minimal nostr bookmark client

+
+ + {!isAuthenticated ? ( + setIsAuthenticated(true)} /> + ) : ( + setIsAuthenticated(false)} /> + )} +
+
) } diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index 0f00788e..454ce21f 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -1,5 +1,5 @@ import { useState, useEffect, useContext } from 'react' -import { EventStoreContext } from 'applesauce-react' +import { EventStoreContext, Hooks } from 'applesauce-react' import { NostrEvent } from 'nostr-tools' interface Bookmark { @@ -11,31 +11,24 @@ interface Bookmark { tags: string[][] } -interface UserProfile { - name?: string - username?: string - nip05?: string -} - interface BookmarksProps { - userPublicKey: string | null - userProfile: UserProfile | null onLogout: () => void } -const Bookmarks: React.FC = ({ userPublicKey, userProfile, onLogout }) => { +const Bookmarks: React.FC = ({ onLogout }) => { const [bookmarks, setBookmarks] = useState([]) const [loading, setLoading] = useState(true) const eventStore = useContext(EventStoreContext) + const activeAccount = Hooks.useActiveAccount() useEffect(() => { - if (eventStore && userPublicKey) { + if (eventStore && activeAccount) { fetchBookmarks() } - }, [eventStore, userPublicKey]) + }, [eventStore, activeAccount]) const fetchBookmarks = async () => { - if (!eventStore || !userPublicKey) return + if (!eventStore || !activeAccount) return try { setLoading(true) @@ -46,7 +39,7 @@ const Bookmarks: React.FC = ({ userPublicKey, userProfile, onLog const events = eventStore.getByFilters([ { kinds: [10003, 30003], - authors: [userPublicKey] + authors: [activeAccount.pubkey] } ]) @@ -111,23 +104,12 @@ const Bookmarks: React.FC = ({ userPublicKey, userProfile, onLog return new Date(timestamp * 1000).toLocaleDateString() } - const formatUserDisplay = (profile: UserProfile | null, publicKey: string | null) => { - if (!profile || (!profile.name && !profile.username && !profile.nip05)) { - return publicKey ? `${publicKey.slice(0, 8)}...${publicKey.slice(-8)}` : 'Unknown User' - } + const formatUserDisplay = () => { + if (!activeAccount) return 'Unknown User' - // Priority: NIP-05 > name > username - if (profile.nip05) { - return profile.nip05 - } - if (profile.name) { - return profile.name - } - if (profile.username) { - return `@${profile.username}` - } - - return publicKey ? `${publicKey.slice(0, 8)}...${publicKey.slice(-8)}` : 'Unknown User' + // For now, just show the formatted public key + // TODO: Implement profile fetching through applesauce system + return `${activeAccount.pubkey.slice(0, 8)}...${activeAccount.pubkey.slice(-8)}` } if (loading) { @@ -136,8 +118,8 @@ const Bookmarks: React.FC = ({ userPublicKey, userProfile, onLog

Your Bookmarks

- {userPublicKey && ( -

Logged in as: {formatUserDisplay(userProfile, userPublicKey)}

+ {activeAccount && ( +

Logged in as: {formatUserDisplay()}

)}