diff --git a/src/app/channel/pages/index.page.tsx b/src/app/channel/pages/index.page.tsx index c7b4b4d1..b4247f1f 100644 --- a/src/app/channel/pages/index.page.tsx +++ b/src/app/channel/pages/index.page.tsx @@ -4,13 +4,44 @@ import { ChannelMessageForm } from "@app/channel/components/messages/form"; import { ChannelMetadata } from "@app/channel/components/metadata"; import { RelayContext } from "@shared/relayProvider"; import { useChannelMessages } from "@stores/channels"; -import { dateToUnix } from "@utils/date"; +import { dateToUnix, getHourAgo } from "@utils/date"; import { usePageContext } from "@utils/hooks/usePageContext"; import { LumeEvent } from "@utils/types"; import { useCallback, useContext, useEffect, useRef } from "react"; import { Virtuoso } from "react-virtuoso"; import useSWRSubscription from "swr/subscription"; +const now = new Date(); + +const Header = ( +
+
+
+
+
+
+ {getHourAgo(24, now).toLocaleDateString("en-US", { + weekday: "long", + year: "numeric", + month: "long", + day: "numeric", + })} +
+
+
+); + +const Empty = ( +
+

+ Nothing to see here yet +

+

+ Be the first to share a message in this channel. +

+
+); + export function Page() { const ndk = useContext(RelayContext); const pageContext = usePageContext(); @@ -97,6 +128,10 @@ export function Page() { overscan={50} increaseViewportBy={{ top: 200, bottom: 200 }} className="scrollbar-hide overflow-y-auto h-full w-full" + components={{ + Header: () => Header, + EmptyPlaceholder: () => Empty, + }} /> )}
diff --git a/src/app/chat/components/messageList.tsx b/src/app/chat/components/messageList.tsx index 2759bb1f..751a8a60 100644 --- a/src/app/chat/components/messageList.tsx +++ b/src/app/chat/components/messageList.tsx @@ -1,9 +1,41 @@ import { ChatMessageItem } from "@app/chat/components/messages/item"; import { useActiveAccount } from "@stores/accounts"; import { useChatMessages } from "@stores/chats"; +import { getHourAgo } from "@utils/date"; import { useCallback, useRef } from "react"; import { Virtuoso } from "react-virtuoso"; +const now = new Date(); + +const Header = ( +
+
+
+
+
+
+ {getHourAgo(24, now).toLocaleDateString("en-US", { + weekday: "long", + year: "numeric", + month: "long", + day: "numeric", + })} +
+
+
+); + +const Empty = ( +
+

+ Nothing to see here yet +

+

+ You two didn't talk yet, let's send first message +

+
+); + export function ChatMessageList() { const account = useActiveAccount((state: any) => state.account); const messages = useChatMessages((state: any) => state.messages); @@ -43,6 +75,10 @@ export function ChatMessageList() { overscan={50} increaseViewportBy={{ top: 200, bottom: 200 }} className="scrollbar-hide h-full w-full overflow-y-auto" + components={{ + Header: () => Header, + EmptyPlaceholder: () => Empty, + }} />
); diff --git a/src/shared/icons/empty.tsx b/src/shared/icons/empty.tsx new file mode 100644 index 00000000..cdae3e6e --- /dev/null +++ b/src/shared/icons/empty.tsx @@ -0,0 +1,66 @@ +import { SVGProps } from "react"; + +export function EmptyIcon( + props: JSX.IntrinsicAttributes & SVGProps, +) { + return ( + + + + + + + + + + + + + + + + + + + + + ); +} diff --git a/src/shared/icons/index.tsx b/src/shared/icons/index.tsx index f120ff5a..bcf63e02 100644 --- a/src/shared/icons/index.tsx +++ b/src/shared/icons/index.tsx @@ -34,4 +34,5 @@ export * from "./world"; export * from "./zap"; export * from "./loader"; export * from "./trending"; +export * from "./empty"; // @endindex diff --git a/src/shared/notes/kind1.tsx b/src/shared/notes/kind1.tsx index ced00626..e1bb0b7b 100644 --- a/src/shared/notes/kind1.tsx +++ b/src/shared/notes/kind1.tsx @@ -1,8 +1,7 @@ -import { LinkPreview } from "./preview/link"; import { MentionNote } from "@shared/notes/mentions/note"; import { ImagePreview } from "@shared/notes/preview/image"; +import { LinkPreview } from "@shared/notes/preview/link"; import { VideoPreview } from "@shared/notes/preview/video"; -import { truncateContent } from "@utils/transform"; export function Kind1({ content, @@ -11,7 +10,7 @@ export function Kind1({ return ( <>
diff --git a/src/shared/notes/replies/list.tsx b/src/shared/notes/replies/list.tsx index 34b777d5..a67b6832 100644 --- a/src/shared/notes/replies/list.tsx +++ b/src/shared/notes/replies/list.tsx @@ -1,4 +1,5 @@ import { NDKEvent, NDKFilter } from "@nostr-dev-kit/ndk"; +import { EmptyIcon } from "@shared/icons"; import { Reply } from "@shared/notes/replies/item"; import { RelayContext } from "@shared/relayProvider"; import { useContext } from "react"; @@ -35,8 +36,11 @@ export function RepliesList({ id }: { id: string }) {
) : data.length === 0 ? (
-
-

No replies...

+
+
+ +

No replies

+
) : (