Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(dashboard): render anonymous viewer notifications

Richie McIlroy2ca2f56c96b2
diff --git a/apps/web/app/(org)/dashboard/_components/Notifications/NotificationItem.tsx b/apps/web/app/(org)/dashboard/_components/Notifications/NotificationItem.tsx
index 90ad061e9..e58dd8c20 100644
--- a/apps/web/app/(org)/dashboard/_components/Notifications/NotificationItem.tsx
+++ b/apps/web/app/(org)/dashboard/_components/Notifications/NotificationItem.tsx
@@ -19,7 +19,7 @@ const descriptionMap: Record<NotificationType, string> = {
reply: `replied to your comment`,
view: `viewed your video`,
reaction: `reacted to your video`,
- // mention: `mentioned you in a comment`,
+ anon_view: `viewed your video`,
};
export const NotificationItem = ({
@@ -36,6 +36,11 @@ export const NotificationItem = ({
}
};
+ const isAnonView = notification.type === "anon_view";
+ const displayName = isAnonView
+ ? notification.anonName
+ : notification.author.name;
+
return (
<Link
href={link}
@@ -45,30 +50,39 @@ export const NotificationItem = ({
className,
)}
>
- {/* Avatar */}
<div className="relative flex-shrink-0">
- <SignedImageUrl
- image={notification.author.avatar as ImageUpload.ImageUrl | null}
- name={notification.author.name}
- className="relative flex-shrink-0 size-7"
- letterClass="text-sm"
- />
+ {isAnonView ? (
+ <div className="relative flex-shrink-0 size-7 rounded-full bg-gray-3 flex items-center justify-center text-sm">
+ 🐾
+ </div>
+ ) : (
+ <SignedImageUrl
+ image={notification.author.avatar as ImageUpload.ImageUrl | null}
+ name={notification.author.name}
+ className="relative flex-shrink-0 size-7"
+ letterClass="text-sm"
+ />
+ )}
{notification.readAt === null && (
<div className="absolute top-0 right-0 size-2.5 rounded-full bg-red-500 border-2 border-gray-1"></div>
)}
</div>
- {/* Content */}
<div className="flex flex-col flex-1 justify-center">
<div className="flex gap-1 items-center">
<span className="font-medium text-gray-12 text-[13px]">
- {notification.author.name}
+ {displayName}
</span>
<span className="text-gray-10 text-[13px]">
{descriptionMap[notification.type]}
</span>
</div>
+ {isAnonView && notification.location && (
+ <p className="text-[13px] leading-4 text-gray-11">
+ {notification.location}
+ </p>
+ )}
{(notification.type === "comment" || notification.type === "reply") && (
<p className="mb-2 text-[13px] h-fit italic leading-4 text-gray-11 line-clamp-2">
{notification.comment.content}
@@ -79,7 +93,6 @@ export const NotificationItem = ({
</p>
</div>
- {/* Icon */}
<div className="flex flex-shrink-0 items-center mt-1">
{notification.type === "comment" && (
<FontAwesomeIcon icon={faComment} className="text-gray-10 size-4" />
@@ -87,7 +100,8 @@ export const NotificationItem = ({
{notification.type === "reply" && (
<FontAwesomeIcon icon={faReply} className="text-gray-10 size-4" />
)}
- {notification.type === "view" && (
+ {(notification.type === "view" ||
+ notification.type === "anon_view") && (
<FontAwesomeIcon icon={faEye} className="text-gray-10 size-4" />
)}
{notification.type === "reaction" && (
@@ -104,9 +118,9 @@ function getLink(notification: APINotification) {
return `/s/${notification.videoId}/?reply=${notification.comment.id}`;
case "comment":
case "reaction":
- // case "mention":
return `/s/${notification.videoId}/?comment=${notification.comment.id}`;
- default:
+ case "view":
+ case "anon_view":
return `/s/${notification.videoId}`;
}
}