+
twMerge(
- 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 pl-4 pr-3 font-medium',
+ 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 px-3 font-medium',
isActive
? 'border-fuchsia-500 bg-white/5 text-white'
: 'border-transparent text-white/70'
@@ -72,12 +73,29 @@ export function Navigation() {
Home
+
+ twMerge(
+ 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 px-3 font-medium',
+ isActive
+ ? 'border-fuchsia-500 bg-white/5 text-white'
+ : 'border-transparent text-white/70'
+ )
+ }
+ >
+
+
+
+ Chats
+
twMerge(
- 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 pl-4 pr-3 font-medium',
+ 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 px-3 font-medium',
isActive
? 'border-fuchsia-500 bg-white/5 text-white'
: 'border-transparent text-white/70'
@@ -94,7 +112,7 @@ export function Navigation() {
preventScrollReset={true}
className={({ isActive }) =>
twMerge(
- 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 pl-4 pr-3 font-medium',
+ 'flex h-10 items-center gap-2.5 rounded-r-lg border-l-2 px-3 font-medium',
isActive
? 'border-fuchsia-500 bg-white/5 text-white'
: 'border-transparent text-white/70'
diff --git a/src/shared/notes/kinds/text.tsx b/src/shared/notes/kinds/text.tsx
index 82f34e7b..6f2a3dab 100644
--- a/src/shared/notes/kinds/text.tsx
+++ b/src/shared/notes/kinds/text.tsx
@@ -23,7 +23,7 @@ export function TextNote(props: { content?: string }) {
diff --git a/src/utils/hooks/useNostr.ts b/src/utils/hooks/useNostr.ts
index 9aae02ac..9d24d449 100644
--- a/src/utils/hooks/useNostr.ts
+++ b/src/utils/hooks/useNostr.ts
@@ -168,23 +168,6 @@ export function useNostr() {
}
};
- const fetchNIP04Chats = async () => {
- const events = await fetcher.fetchAllEvents(
- relayUrls,
- {
- kinds: [NDKKind.EncryptedDirectMessage],
- '#p': [db.account.pubkey],
- },
- { since: 0 }
- );
-
- const senders = events.map((e) => e.pubkey);
- const follows = new Set(senders.filter((el) => db.account.follows.includes(el)));
- const unknowns = new Set(senders.filter((el) => !db.account.follows.includes(el)));
-
- return { follows: [...follows], unknowns: [...unknowns] };
- };
-
const fetchNIP04Messages = async (sender: string) => {
let senderMessages: NostrEventExt[] = [];
@@ -258,6 +241,32 @@ export function useNostr() {
return events;
};
+ const getAllNIP04Chats = async () => {
+ const events = await fetcher.fetchAllEvents(
+ relayUrls,
+ {
+ kinds: [NDKKind.EncryptedDirectMessage],
+ '#p': [db.account.pubkey],
+ },
+ { since: 0 }
+ );
+
+ const dedup: NDKEvent[] = Object.values(
+ events.reduce((ev, { id, content, pubkey, created_at, tags }) => {
+ if (ev[pubkey]) {
+ if (ev[pubkey].created_at < created_at) {
+ ev[pubkey] = { id, content, pubkey, created_at, tags };
+ }
+ } else {
+ ev[pubkey] = { id, content, pubkey, created_at, tags };
+ }
+ return ev;
+ }, {})
+ );
+
+ return dedup;
+ };
+
const getAllEventsSinceLastLogin = async (customSince?: number) => {
try {
let since: number;
@@ -465,9 +474,9 @@ export function useNostr() {
fetchUserData,
addContact,
removeContact,
+ getAllNIP04Chats,
getAllEventsSinceLastLogin,
fetchActivities,
- fetchNIP04Chats,
fetchNIP04Messages,
fetchAllReplies,
publish,