From 976985a28fc3ede26cea7d1f36d6dee25df3425e Mon Sep 17 00:00:00 2001 From: celine Date: Tue, 11 Nov 2025 23:20:54 +0000 Subject: [PATCH] refactoring to add notification list in popover as well, added timestamp --- app/(home-pages)/notifications/CommentNotication.tsx | 12 +++--------- app/(home-pages)/notifications/FollowNotification.tsx | 6 ++---- app/(home-pages)/notifications/MentionNotification.tsx | 9 +++------ app/(home-pages)/notifications/Notification.tsx | 39 ++++++++++++++++++++++++++++----------- app/(home-pages)/notifications/NotificationList.tsx | 22 +++------------------- app/(home-pages)/notifications/ReplyNotification.tsx | 12 +++--------- 6 file(s) changed, 42 insertion(s)(+), 58 deletion(s)(-) diff --git a/app/(home-pages)/notifications/CommentNotication.tsx b/app/(home-pages)/notifications/CommentNotication.tsx --- a/app/(home-pages)/notifications/CommentNotication.tsx +++ b/app/(home-pages)/notifications/CommentNotication.tsx @@ -16,9 +16,7 @@ } from "./Notification"; import { AtUri } from "@atproto/api"; -export const CommentNotification = ( - props: { cardBorderHidden: boolean } & HydratedCommentNotification, -) => { +export const CommentNotification = (props: HydratedCommentNotification) => { let docRecord = props.commentData.documents ?.data as PubLeafletDocument.Record; let commentRecord = props.commentData.record as PubLeafletComment.Record; @@ -34,16 +32,12 @@ return ( } actionText={<>{displayName} commented on your post} content={ - + { +export const DummyFollowNotification = (props: {}) => { const identity = "celine"; const pubName = "Pub Name Here"; return ( } - cardBorderHidden={props.cardBorderHidden} actionText={ <> {identity} followed {pubName}! diff --git a/app/(home-pages)/notifications/MentionNotification.tsx b/app/(home-pages)/notifications/MentionNotification.tsx --- a/app/(home-pages)/notifications/MentionNotification.tsx +++ b/app/(home-pages)/notifications/MentionNotification.tsx @@ -1,19 +1,16 @@ import { MentionTiny } from "components/Icons/MentionTiny"; import { ContentLayout, Notification } from "./Notification"; -export const DummyPostMentionNotification = (props: { - cardBorderHidden: boolean; -}) => { +export const DummyPostMentionNotification = (props: {}) => { return ( } - cardBorderHidden={props.cardBorderHidden} actionText={<>celine mentioned your post} content={ I'm just gonna put the description here. The surrounding context is @@ -35,6 +32,7 @@ }) => { return ( } actionText={<>celine mentioned you} @@ -42,7 +40,6 @@
...llo this is the content of a post or whatever here it comes{" "} diff --git a/app/(home-pages)/notifications/Notification.tsx b/app/(home-pages)/notifications/Notification.tsx --- a/app/(home-pages)/notifications/Notification.tsx +++ b/app/(home-pages)/notifications/Notification.tsx @@ -1,23 +1,30 @@ +"use client"; import { Avatar } from "components/Avatar"; import { BaseTextBlock } from "app/lish/[did]/[publication]/[rkey]/BaseTextBlock"; import { PubLeafletPublication, PubLeafletRichtextFacet } from "lexicons/api"; +import { timeAgo } from "src/utils/timeAgo"; +import { useReplicache, useEntity } from "src/replicache"; export const Notification = (props: { icon: React.ReactNode; actionText: React.ReactNode; content?: React.ReactNode; - cardBorderHidden?: boolean; + timestamp: string; href: string; }) => { + let { rootEntity } = useReplicache(); + let cardBorderHidden = useEntity(rootEntity, "theme/card-border-hidden")?.data + .value; + return (
-
-
{props.icon}
-
{props.actionText}
+
+
+
{props.icon}
+
+ {props.actionText} +
+
+
+ {timeAgo(props.timestamp)} +
{props.content && (
@@ -44,11 +58,14 @@ children: React.ReactNode; postTitle: string; pubRecord?: PubLeafletPublication.Record; - cardBorderHidden: boolean; }) => { + let { rootEntity } = useReplicache(); + let cardBorderHidden = useEntity(rootEntity, "theme/card-border-hidden")?.data + .value; + return (
{props.postTitle} diff --git a/app/(home-pages)/notifications/NotificationList.tsx b/app/(home-pages)/notifications/NotificationList.tsx --- a/app/(home-pages)/notifications/NotificationList.tsx +++ b/app/(home-pages)/notifications/NotificationList.tsx @@ -17,9 +17,6 @@ markAsRead(); }, 500); }, []); - let { rootEntity } = useReplicache(); - let cardBorderHidden = useEntity(rootEntity, "theme/card-border-hidden")?.data - .value; if (notifications.length === 0) return ( @@ -29,24 +26,11 @@ ); return (
-
+
{notifications.map((n) => { if (n.type === "comment") { - if (n.parentData) - return ( - - ); - return ( - - ); + if (n.parentData) return ; + return ; } })}
diff --git a/app/(home-pages)/notifications/ReplyNotification.tsx b/app/(home-pages)/notifications/ReplyNotification.tsx --- a/app/(home-pages)/notifications/ReplyNotification.tsx +++ b/app/(home-pages)/notifications/ReplyNotification.tsx @@ -15,9 +15,7 @@ import { AppBskyActorProfile, AtUri } from "@atproto/api"; import { blobRefToSrc } from "src/utils/blobRefToSrc"; -export const ReplyNotification = ( - props: { cardBorderHidden: boolean } & HydratedCommentNotification, -) => { +export const ReplyNotification = (props: HydratedCommentNotification) => { let docRecord = props.commentData.documents ?.data as PubLeafletDocument.Record; let commentRecord = props.commentData.record as PubLeafletComment.Record; @@ -42,16 +40,12 @@ return ( } actionText={`${displayName} replied to your comment`} - cardBorderHidden={props.cardBorderHidden} content={ - +