diff --git a/src/app/chats/chat.tsx b/src/app/chats/chat.tsx index f9d15696..5dfeb321 100644 --- a/src/app/chats/chat.tsx +++ b/src/app/chats/chat.tsx @@ -11,6 +11,7 @@ import { useNDK } from '@libs/ndk/provider'; import { useStorage } from '@libs/storage/provider'; import { LoaderIcon } from '@shared/icons'; +import { User } from '@shared/user'; import { useStronghold } from '@stores/stronghold'; @@ -35,6 +36,7 @@ export function ChatScreen() { message={message} userPubkey={db.account.pubkey} userPrivkey={userPrivkey} + self={message.pubkey === db.account.pubkey} /> ); }, @@ -71,7 +73,10 @@ export function ChatScreen() {
-
+
+ +
+
{status === 'loading' ? (
@@ -92,7 +97,7 @@ export function ChatScreen() { )}
-
+
-
-
+
+
+
+
+
+
); } @@ -55,24 +58,28 @@ export const ChatListItem = memo(function ChatListItem({ event }: { event: NDKEv loading="lazy" decoding="async" style={{ contentVisibility: 'auto' }} - className="h-9 w-9 rounded-lg" + className="h-10 w-10 rounded-lg" /> - {event.pubkey} + {event.pubkey}
-
+
{user?.name || user?.display_name || user?.displayName || displayNpub(event.pubkey, 16)} -
+
-

+

{decryptedContent} -

-

{createdAt}

+
+
{createdAt}
diff --git a/src/app/chats/components/message.tsx b/src/app/chats/components/message.tsx index 58e1f071..e8ae7638 100644 --- a/src/app/chats/components/message.tsx +++ b/src/app/chats/components/message.tsx @@ -1,9 +1,9 @@ import { NDKEvent } from '@nostr-dev-kit/ndk'; +import { twMerge } from 'tailwind-merge'; import { useDecryptMessage } from '@app/chats/hooks/useDecryptMessage'; import { ImagePreview, LinkPreview, MentionNote, VideoPreview } from '@shared/notes'; -import { User } from '@shared/user'; import { parser } from '@utils/parser'; @@ -11,44 +11,41 @@ export function ChatMessage({ message, userPubkey, userPrivkey, + self, }: { message: NDKEvent; userPubkey: string; userPrivkey: string; + self: boolean; }) { const decryptedContent = useDecryptMessage(message, userPubkey, userPrivkey); const richContent = parser(decryptedContent) ?? null; return ( -
-
- -
-
- {!richContent ? ( -

Decrypting...

- ) : ( -
-

- {richContent.parsed} -

-
- {richContent.images.length > 0 && ( - - )} - {richContent.videos.length > 0 && ( - - )} - {richContent.links.length > 0 && } - {richContent.notes.length > 0 && - richContent.notes.map((note: string) => ( - - ))} -
-
- )} +
+ {!richContent ? ( +

Decrypting...

+ ) : ( +
+

+ {richContent.parsed} +

+
+ {richContent.images.length > 0 && } + {richContent.videos.length > 0 && } + {richContent.links.length > 0 && } + {richContent.notes.length > 0 && + richContent.notes.map((note: string) => ( + + ))} +
-
+ )}
); } diff --git a/src/app/chats/index.tsx b/src/app/chats/index.tsx index 86a73ca8..6d12c1d5 100644 --- a/src/app/chats/index.tsx +++ b/src/app/chats/index.tsx @@ -16,7 +16,12 @@ export function ChatsScreen() { async () => { return await getAllNIP04Chats(); }, - { refetchOnWindowFocus: false } + { + refetchOnWindowFocus: false, + refetchOnMount: false, + refetchOnReconnect: false, + staleTime: Infinity, + } ); const renderItem = useCallback( @@ -31,9 +36,13 @@ export function ChatsScreen() {
-
+ className="flex h-11 w-full shrink-0 items-center border-b border-white/5 px-3" + > +

+ All chats +

+
+
{status === 'loading' ? (
diff --git a/src/app/space/components/widgetList.tsx b/src/app/space/components/widgetList.tsx index ec2c5851..3ceeb91e 100644 --- a/src/app/space/components/widgetList.tsx +++ b/src/app/space/components/widgetList.tsx @@ -57,9 +57,9 @@ export function WidgetList({ params }: { params: Widget }) { ); const renderItem = useCallback( - (row: WidgetGroup) => { + (row: WidgetGroup, index: number) => { return ( -
+

{row.title}

{row.data.map((item, index) => ( @@ -101,7 +101,9 @@ export function WidgetList({ params }: { params: Widget }) {
- {DefaultWidgets.map((row: WidgetGroup) => renderItem(row))} + {DefaultWidgets.map((row: WidgetGroup, index: number) => + renderItem(row, index) + )}