From a8c7c43af14365e594bcbf889c27f5cd481dfe23 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 12 Oct 2026 20:49:36 +0300 Subject: [PATCH] APP-3324: Bring Notifications v2 up to the new design sizes and badge icons (#11952) Co-authored-by: Claude Opus 5.5 --- .../ui/Megaphone_Filled_Corner0_Rounded.svg | 1 + ...onActivitySmall_Filled_Corner0_Rounded.svg | 1 + ...tionFollowSmall_Filled_Corner0_Rounded.svg | 1 + ...cationLikeSmall_Filled_Corner0_Rounded.svg | 1 + ...ionMentionSmall_Filled_Corner0_Rounded.svg | 1 + ...ationQuoteSmall_Filled_Corner0_Rounded.svg | 1 + ...ationReplySmall_Filled_Corner0_Rounded.svg | 1 + ...tionRepostSmall_Filled_Corner0_Rounded.svg | 1 + ...tarterPackSmall_Filled_Corner0_Rounded.svg | 1 + ...onVerifiedSmall_Filled_Corner0_Rounded.svg | 1 + lexicons.json | 2 +- .../notification/getGroupedNotifications.json | 122 ++++++++++- src/components/icons/Megaphone.tsx | 8 + src/components/icons/Notification.tsx | 58 ++++++ .../NotificationItem/Item/Avatar.tsx | 20 +- .../components/NotificationItem/Item/Root.tsx | 12 +- .../NotificationItem/Item/aggregate.tsx | 12 +- .../components/NotificationItem/Item/post.tsx | 20 +- .../NotificationItem/Item/profile.tsx | 18 +- .../components/NotificationItem/Item/text.tsx | 10 +- .../components/NotificationItem/index.tsx | 11 + .../NotificationItem/kinds/aggregate.tsx | 195 +++++++++++++++--- .../NotificationItem/kinds/follower.tsx | 9 +- .../NotificationItem/kinds/post.tsx | 14 +- .../NotificationItem/kinds/profile.tsx | 10 +- .../grouped/__fixtures__/index.ts | 75 ++++--- .../grouped/__tests__/follow-actors.test.ts | 8 +- .../grouped/__tests__/hydrate.test.ts | 65 +++++- .../queries/notifications/grouped/hydrate.ts | 53 +++-- .../queries/notifications/grouped/index.ts | 8 +- .../queries/notifications/grouped/moderate.ts | 10 +- .../queries/notifications/grouped/types.ts | 27 ++- .../screens/DebugMod/GroupedNotifications.tsx | 46 ++++- src/view/screens/DebugMod/mock.ts | 9 +- 34 files changed, 697 insertions(+), 135 deletions(-) create mode 100644 assets/icons/ui/Megaphone_Filled_Corner0_Rounded.svg create mode 100644 assets/icons/ui/NotificationActivitySmall_Filled_Corner0_Rounded.svg create mode 100644 assets/icons/ui/NotificationFollowSmall_Filled_Corner0_Rounded.svg create mode 100644 assets/icons/ui/NotificationLikeSmall_Filled_Corner0_Rounded.svg create mode 100644 assets/icons/ui/NotificationMentionSmall_Filled_Corner0_Rounded.svg create mode 100644 assets/icons/ui/NotificationQuoteSmall_Filled_Corner0_Rounded.svg create mode 100644 assets/icons/ui/NotificationReplySmall_Filled_Corner0_Rounded.svg create mode 100644 assets/icons/ui/NotificationRepostSmall_Filled_Corner0_Rounded.svg create mode 100644 assets/icons/ui/NotificationStarterPackSmall_Filled_Corner0_Rounded.svg create mode 100644 assets/icons/ui/NotificationVerifiedSmall_Filled_Corner0_Rounded.svg create mode 100644 src/components/icons/Megaphone.tsx create mode 100644 src/components/icons/Notification.tsx diff --git a/assets/icons/ui/Megaphone_Filled_Corner0_Rounded.svg b/assets/icons/ui/Megaphone_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..84bd7d5c5 --- /dev/null +++ b/assets/icons/ui/Megaphone_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/ui/NotificationActivitySmall_Filled_Corner0_Rounded.svg b/assets/icons/ui/NotificationActivitySmall_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..0a448e019 --- /dev/null +++ b/assets/icons/ui/NotificationActivitySmall_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/ui/NotificationFollowSmall_Filled_Corner0_Rounded.svg b/assets/icons/ui/NotificationFollowSmall_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..670cd5fff --- /dev/null +++ b/assets/icons/ui/NotificationFollowSmall_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/ui/NotificationLikeSmall_Filled_Corner0_Rounded.svg b/assets/icons/ui/NotificationLikeSmall_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..cf191ffa7 --- /dev/null +++ b/assets/icons/ui/NotificationLikeSmall_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/ui/NotificationMentionSmall_Filled_Corner0_Rounded.svg b/assets/icons/ui/NotificationMentionSmall_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..b336ef3ae --- /dev/null +++ b/assets/icons/ui/NotificationMentionSmall_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/ui/NotificationQuoteSmall_Filled_Corner0_Rounded.svg b/assets/icons/ui/NotificationQuoteSmall_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..a4d915962 --- /dev/null +++ b/assets/icons/ui/NotificationQuoteSmall_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/ui/NotificationReplySmall_Filled_Corner0_Rounded.svg b/assets/icons/ui/NotificationReplySmall_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..667f4c690 --- /dev/null +++ b/assets/icons/ui/NotificationReplySmall_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/ui/NotificationRepostSmall_Filled_Corner0_Rounded.svg b/assets/icons/ui/NotificationRepostSmall_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..ffb274e09 --- /dev/null +++ b/assets/icons/ui/NotificationRepostSmall_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/ui/NotificationStarterPackSmall_Filled_Corner0_Rounded.svg b/assets/icons/ui/NotificationStarterPackSmall_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..ea8fbe65c --- /dev/null +++ b/assets/icons/ui/NotificationStarterPackSmall_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/ui/NotificationVerifiedSmall_Filled_Corner0_Rounded.svg b/assets/icons/ui/NotificationVerifiedSmall_Filled_Corner0_Rounded.svg new file mode 100644 index 000000000..7db9e1b7f --- /dev/null +++ b/assets/icons/ui/NotificationVerifiedSmall_Filled_Corner0_Rounded.svg @@ -0,0 +1 @@ + diff --git a/lexicons.json b/lexicons.json index 64224ae16..91ada640f 100644 --- a/lexicons.json +++ b/lexicons.json @@ -701,7 +701,7 @@ }, "app.bsky.notification.getGroupedNotifications": { "uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.notification.getGroupedNotifications", - "cid": "bafyreihyv25gx7iysovm7k7nohyb4i5yiutkvtbyk6hzwhm5cnu3apim3m" + "cid": "bafyreierpxcqidgy57zawmtvlh5kg6paj2a3njo5cy3kj46uwkl3jyyfii" }, "app.bsky.notification.getPreferences": { "uri": "at://did:plc:4v4y5r3lwsbtmsxhile2ljac/com.atproto.lexicon.schema/app.bsky.notification.getPreferences", diff --git a/lexicons/app/bsky/notification/getGroupedNotifications.json b/lexicons/app/bsky/notification/getGroupedNotifications.json index ca8006388..a47deb416 100644 --- a/lexicons/app/bsky/notification/getGroupedNotifications.json +++ b/lexicons/app/bsky/notification/getGroupedNotifications.json @@ -30,12 +30,12 @@ "type": "array", "items": { "refs": [ - "app.bsky.actor.defs#profileViewDetailed", + "app.bsky.actor.defs#profileViewBasic", "app.bsky.feed.defs#blockedPost", "app.bsky.feed.defs#generatorView", "app.bsky.feed.defs#notFoundPost", "app.bsky.feed.defs#postView", - "app.bsky.graph.defs#starterPackView" + "app.bsky.graph.defs#starterPackViewBasic" ], "type": "union" }, @@ -94,6 +94,9 @@ "refs": [ "#likeGroup", "#multiPostLikeGroup", + "#multiPostRepostGroup", + "#multiPostLikeViaRepostGroup", + "#multiPostRepostViaRepostGroup", "#repostGroup", "#likeViaRepostGroup", "#repostViaRepostGroup", @@ -409,6 +412,19 @@ }, "description": "A post mentioning the requesting account." }, + "multiPostRepostItem": { + "type": "object", + "required": [ + "post" + ], + "properties": { + "post": { + "type": "string", + "format": "at-uri" + } + }, + "description": "One post which was reposted by the group's actor." + }, "repostViaRepostItem": { "type": "object", "required": [ @@ -439,6 +455,28 @@ }, "description": "Group of new posts by actors the requesting account subscribes to." }, + "multiPostRepostGroup": { + "type": "object", + "required": [ + "actor", + "items" + ], + "properties": { + "actor": { + "type": "string", + "format": "did" + }, + "items": { + "type": "array", + "items": { + "ref": "#multiPostRepostItem", + "type": "ref" + }, + "minLength": 2 + } + }, + "description": "Group of reposts by the same actor of different posts." + }, "repostViaRepostGroup": { "type": "object", "required": [ @@ -522,6 +560,86 @@ }, "description": "A contact of the requesting account joined Bluesky." }, + "multiPostLikeViaRepostItem": { + "type": "object", + "required": [ + "post", + "viaRepost" + ], + "properties": { + "post": { + "type": "string", + "format": "at-uri" + }, + "viaRepost": { + "type": "string", + "format": "at-uri" + } + }, + "description": "One post which was liked by the group's actor via the requesting account's repost." + }, + "multiPostLikeViaRepostGroup": { + "type": "object", + "required": [ + "actor", + "items" + ], + "properties": { + "actor": { + "type": "string", + "format": "did" + }, + "items": { + "type": "array", + "items": { + "ref": "#multiPostLikeViaRepostItem", + "type": "ref" + }, + "minLength": 2 + } + }, + "description": "Group of likes by the same actor on different posts via the requesting account's reposts." + }, + "multiPostRepostViaRepostItem": { + "type": "object", + "required": [ + "post", + "viaRepost" + ], + "properties": { + "post": { + "type": "string", + "format": "at-uri" + }, + "viaRepost": { + "type": "string", + "format": "at-uri" + } + }, + "description": "One post which was reposted by the group's actor via the requesting account's repost." + }, + "multiPostRepostViaRepostGroup": { + "type": "object", + "required": [ + "actor", + "items" + ], + "properties": { + "actor": { + "type": "string", + "format": "did" + }, + "items": { + "type": "array", + "items": { + "ref": "#multiPostRepostViaRepostItem", + "type": "ref" + }, + "minLength": 2 + } + }, + "description": "Group of reposts by the same actor of different posts via the requesting account's reposts." + }, "starterPackJoinedNotification": { "type": "object", "required": [ diff --git a/src/components/icons/Megaphone.tsx b/src/components/icons/Megaphone.tsx new file mode 100644 index 000000000..e65c1bd06 --- /dev/null +++ b/src/components/icons/Megaphone.tsx @@ -0,0 +1,8 @@ +// This file is generated by pnpm icons:generate. Do not edit. + +import {createSinglePathSVG} from './TEMPLATE' + +export const Megaphone_Filled_Corner0_Rounded = createSinglePathSVG({ + path: 'M12.5 18.019V19.5a2.5 2.5 0 0 1-5 0v-3h2.57l2.43 1.518Zm3.705-14.584A1.5 1.5 0 0 1 18.5 4.706v12.588a1.5 1.5 0 0 1-2.295 1.271L10.5 15V7l5.705-3.565ZM9 15H5.5a4 4 0 0 1 0-8H9v8Zm11-6a2.5 2.5 0 0 1 0 5V9Z', + viewBox: '0 0 24 24', +}) diff --git a/src/components/icons/Notification.tsx b/src/components/icons/Notification.tsx new file mode 100644 index 000000000..c5e9daa64 --- /dev/null +++ b/src/components/icons/Notification.tsx @@ -0,0 +1,58 @@ +// This file is generated by pnpm icons:generate. Do not edit. + +import {createSinglePathSVG} from './TEMPLATE' + +export const NotificationActivitySmall_Filled_Corner0_Rounded = + createSinglePathSVG({ + path: 'M6 1a3.654 3.654 0 0 0-3.65 3.471l-.084 1.69a1 1 0 0 1-.104.397L1.595 7.69A.904.904 0 0 0 2.405 9H3.55a2.5 2.5 0 0 0 4.9 0h1.146a.904.904 0 0 0 .809-1.309l-.567-1.133a1 1 0 0 1-.104-.397l-.085-1.69A3.654 3.654 0 0 0 6 1Zm0 9a1.5 1.5 0 0 1-1.415-1h2.83A1.5 1.5 0 0 1 6 10Z', + viewBox: '0 0 12 12', + }) + +export const NotificationFollowSmall_Filled_Corner0_Rounded = + createSinglePathSVG({ + path: 'M2.75 3.25a2.25 2.25 0 1 1 4.5 0 2.25 2.25 0 0 1-4.5 0ZM1.023 8.758C1.618 7.148 3.085 6 5.001 6s3.382 1.148 3.977 2.758c.17.46.054.914-.216 1.236a1.45 1.45 0 0 1-1.11.506H2.35c-.438 0-.845-.191-1.11-.506a1.23 1.23 0 0 1-.216-1.236ZM8.85 6.65V5.8H8a.65.65 0 1 1 0-1.3h.85v-.85a.65.65 0 1 1 1.3 0v.85H11a.65.65 0 1 1 0 1.3h-.85v.85a.65.65 0 1 1-1.3 0Z', + viewBox: '0 0 12 12', + }) + +export const NotificationLikeSmall_Filled_Corner0_Rounded = createSinglePathSVG( + { + path: 'M6.244 10.686c4.264-2.39 5.313-5.235 4.511-7.235-.389-.97-1.206-1.666-2.17-1.881-.85-.19-1.777.001-2.585.643-.808-.642-1.736-.833-2.585-.643-.964.215-1.781.91-2.17 1.881-.802 2 .247 4.845 4.51 7.235a.5.5 0 0 0 .49 0Z', + viewBox: '0 0 12 12', + }, +) + +export const NotificationMentionSmall_Filled_Corner0_Rounded = + createSinglePathSVG({ + path: 'M3.413 5.67c.188-1.337 1.326-2.435 2.691-2.244.412.058.772.224 1.069.464a.65.65 0 0 1 1.184.453l-.258 1.772a.96.96 0 0 0 .865 1.094c.32.03.501-.085.632-.264.155-.214.254-.555.254-.945a3.85 3.85 0 1 0-1.824 3.274.65.65 0 0 1 .685 1.105A5.15 5.15 0 1 1 11.15 6c0 .574-.14 1.211-.503 1.71-.388.534-1.005.867-1.8.794a2.25 2.25 0 0 1-1.45-.711c-.499.559-1.218.887-2.015.775-1.365-.191-2.157-1.561-1.969-2.898Zm2.51-.957c-.497-.07-1.11.345-1.222 1.137s.364 1.36.862 1.43c.497.07 1.11-.345 1.222-1.137s-.364-1.36-.862-1.43Z', + viewBox: '0 0 12 12', + }) + +export const NotificationQuoteSmall_Filled_Corner0_Rounded = + createSinglePathSVG({ + path: 'M3.25 2.5a2.25 2.25 0 1 0 .875 4.323q-.08.146-.174.279c-.393.555-.974.979-1.728 1.482a.5.5 0 0 0 .554.832c.746-.497 1.477-1.01 1.99-1.737.528-.746.798-1.67.733-2.943A2.25 2.25 0 0 0 3.25 2.5Zm5.5 0a2.25 2.25 0 1 0 .875 4.323q-.08.146-.174.279c-.393.555-.974.979-1.728 1.482a.5.5 0 0 0 .554.832c.746-.497 1.477-1.01 1.99-1.737.528-.746.798-1.67.733-2.943A2.25 2.25 0 0 0 8.75 2.5Z', + viewBox: '0 0 12 12', + }) + +export const NotificationReplySmall_Filled_Corner0_Rounded = + createSinglePathSVG({ + path: 'M11.001 7.5a2 2 0 0 1-2 2H6.677l-2.363 1.89A.5.5 0 0 1 3.5 11V9.5H3a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v4Z', + viewBox: '0 0 12 12', + }) + +export const NotificationRepostSmall_Filled_Corner0_Rounded = + createSinglePathSVG({ + path: 'M1.25 5.5V5A2.75 2.75 0 0 1 4 2.25h3.94l-.22-.22A.75.75 0 1 1 8.78.97l1.5 1.5a.75.75 0 0 1 0 1.06l-1.5 1.5a.75.75 0 1 1-1.06-1.06l.22-.22H4c-.69 0-1.25.56-1.25 1.25v.5a.75.75 0 1 1-1.5 0Zm9.5 1V7A2.75 2.75 0 0 1 8 9.75H4.06l.22.22a.75.75 0 1 1-1.06 1.06l-1.5-1.5a.75.75 0 0 1 0-1.06l1.5-1.5a.75.75 0 1 1 1.06 1.06l-.22.22H8c.69 0 1.25-.56 1.25-1.25v-.5a.75.75 0 0 1 1.5 0Z', + viewBox: '0 0 12 12', + }) + +export const NotificationStarterPackSmall_Filled_Corner0_Rounded = + createSinglePathSVG({ + path: 'M6.155 2.689a.35.35 0 0 0-.43-.248L1.858 3.478a.35.35 0 0 0-.248.429l1.037 3.868a.35.35 0 0 0 .429.248l3.869-1.037a.35.35 0 0 0 .247-.428l-1.036-3.87ZM8.447 6.22A1.65 1.65 0 0 1 7.28 8.242L3.411 9.28a1.65 1.65 0 0 1-2.02-1.167L.354 4.242a1.65 1.65 0 0 1 1.167-2.02l3.868-1.036a1.65 1.65 0 0 1 2.022 1.166l1.036 3.869Zm2.017.974a2.6 2.6 0 1 0-5.2 0 2.6 2.6 0 0 0 5.2 0Zm1.3 0a3.9 3.9 0 1 1-7.8 0 3.9 3.9 0 0 1 7.8 0Z', + viewBox: '0 0 12 12', + }) + +export const NotificationVerifiedSmall_Filled_Corner0_Rounded = + createSinglePathSVG({ + path: 'M9.822 2.264a.8.8 0 0 1 1.099-.085.73.73 0 0 1 .087 1.057l-5.973 6.75a.8.8 0 0 1-1.117.069l-2.857-2.5a.73.73 0 0 1-.053-1.06.8.8 0 0 1 1.1-.05L4.37 8.424l5.452-6.16Z', + viewBox: '0 0 12 12', + }) diff --git a/src/screens/Notifications/components/NotificationItem/Item/Avatar.tsx b/src/screens/Notifications/components/NotificationItem/Item/Avatar.tsx index 4ca9831ab..d9ec17b63 100644 --- a/src/screens/Notifications/components/NotificationItem/Item/Avatar.tsx +++ b/src/screens/Notifications/components/NotificationItem/Item/Avatar.tsx @@ -6,6 +6,7 @@ import {PreviewableUserAvatar} from '#/view/com/util/UserAvatar' import {atoms as a, useTheme} from '#/alf' import {type Props as SVGIconProps} from '#/components/icons/common' import type * as bsky from '#/types/bsky' +import {useItemBackgroundColor} from './Root' /** * The colour family of a notification's icon badge. @@ -19,8 +20,13 @@ export type BadgeTone = */ const ACTIVITY_ORANGE = '#F26022' -const AVATAR_SIZE = 36 +const AVATAR_SIZE = 40 const BADGE_SIZE = 20 +/** + * The width of the ring around the badge, in the row's background colour, + * which sets it apart from the avatar. + */ +const BADGE_RING = 2 /** * The primary actor's avatar, with an icon badge overlapping its bottom-end @@ -37,6 +43,7 @@ export function Avatar({ tone?: BadgeTone }) { const t = useTheme() + const ringColor = useItemBackgroundColor() const moderationOpts = useModerationOpts() const moderation = moderationOpts ? moderateProfile(profile, moderationOpts) @@ -54,7 +61,10 @@ export function Avatar({ return ( @@ -74,8 +84,10 @@ export function Avatar({ { end: 0, bottom: 0, - width: BADGE_SIZE, - height: BADGE_SIZE, + width: BADGE_SIZE + BADGE_RING * 2, + height: BADGE_SIZE + BADGE_RING * 2, + borderWidth: BADGE_RING, + borderColor: ringColor, backgroundColor: badgeColor, }, ]}> diff --git a/src/screens/Notifications/components/NotificationItem/Item/Root.tsx b/src/screens/Notifications/components/NotificationItem/Item/Root.tsx index 1a466c317..a3afcca67 100644 --- a/src/screens/Notifications/components/NotificationItem/Item/Root.tsx +++ b/src/screens/Notifications/components/NotificationItem/Item/Root.tsx @@ -27,6 +27,16 @@ export function useItemContext() { return useContext(ItemContext) } +/** + * The background colour of the enclosing `Item.Root`, tinted while unread, + * for parts that have to blend into it. + */ +export function useItemBackgroundColor() { + const t = useTheme() + const {isRead} = useItemContext() + return isRead ? t.atoms.bg.backgroundColor : t.palette.primary_25 +} + /** * A notification row: the avatar column, `Item.Content`, and an optional * `Item.Trailing`, laid out horizontally. Pressing anywhere outside a nested @@ -96,7 +106,7 @@ export function Root({ style={[ a.flex_row, a.align_start, - a.gap_md, + a.gap_lg, a.px_lg, a.py_md, isRead ? t.atoms.bg : {backgroundColor: t.palette.primary_25}, diff --git a/src/screens/Notifications/components/NotificationItem/Item/aggregate.tsx b/src/screens/Notifications/components/NotificationItem/Item/aggregate.tsx index d0b9ad848..c09700fb6 100644 --- a/src/screens/Notifications/components/NotificationItem/Item/aggregate.tsx +++ b/src/screens/Notifications/components/NotificationItem/Item/aggregate.tsx @@ -24,7 +24,7 @@ import {SecondaryText} from './text' */ const MAX_PREVIEW_AVATARS = 4 -const PREVIEW_AVATAR_SIZE = 24 +const PREVIEW_AVATAR_SIZE = 32 /** * Small avatars of the other actors in a grouped row, i.e. the "24 others" in @@ -104,7 +104,7 @@ function OverflowChip({count, href}: {count: number; href?: string}) { + style={[a.text_xs, t.atoms.text_contrast_medium]}> {`+${formatCount(i18n, count)}`} @@ -155,7 +155,7 @@ export function PostPreview({ value={new RichTextAPI({text: record.text, facets: record.facets})} authorHandle={post.author.handle} numberOfLines={numberOfLines} - style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_medium, style]} + style={[a.text_md, a.leading_snug, t.atoms.text_contrast_medium, style]} // Links and mentions would otherwise take the muted colour too interactiveStyle={t.atoms.text_link} /> @@ -236,13 +236,13 @@ export function FeedCard({ + style={[a.text_md, a.leading_snug, a.font_semi_bold]}> {generator.displayName} + style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_high]}> Feed by {handle} @@ -273,7 +273,7 @@ export function ViewAllLink({ <> + style={[a.flex_1, a.text_md, a.leading_snug, t.atoms.text]}> {children} @@ -236,7 +236,7 @@ function ReplyContextPost({ 'Shown in place of the text of a post that has no text, only images, video, a link or a quoted post', }) } - const previewStyle = [a.text_sm, a.leading_snug, t.atoms.text_contrast_medium] + const previewStyle = [a.text_md, a.leading_snug, t.atoms.text_contrast_medium] const previewNode = record && preview && !isHidden ? ( )} {post.embed && embedPreview && ( @@ -448,7 +448,7 @@ export function QuoteCard({embed}: {embed: app.bsky.embed.record.View}) { return ( - + {placeholder} @@ -499,7 +499,7 @@ function QuoteCardPost({view}: {view: app.bsky.embed.record.ViewRecord}) { numberOfLines={1} style={[ a.flex_shrink, - a.text_sm, + a.text_md, a.leading_snug, a.font_semi_bold, t.atoms.text, @@ -510,7 +510,7 @@ function QuoteCardPost({view}: {view: app.bsky.embed.record.ViewRecord}) { emoji numberOfLines={1} style={[ - a.text_sm, + a.text_md, a.leading_snug, t.atoms.text_contrast_medium, {flexShrink: 10}, @@ -531,7 +531,7 @@ function QuoteCardPost({view}: {view: app.bsky.embed.record.ViewRecord}) { @@ -552,7 +552,7 @@ function QuoteCardPost({view}: {view: app.bsky.embed.record.ViewRecord}) { // The whole card is already a link disableLinks numberOfLines={2} - style={[a.text_sm, a.leading_snug, t.atoms.text]} + style={[a.text_md, a.leading_snug, t.atoms.text]} /> ) : ( @@ -344,7 +344,7 @@ export function ViaStarterPack({ + style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_medium]}> via starter pack{' '} + style={[a.text_sm, a.font_medium, a.leading_snug, t.atoms.text]}> {name} @@ -391,13 +391,13 @@ export function StarterPackCard({ + style={[a.text_md, a.font_semi_bold, a.leading_snug, t.atoms.text]}> {name} + style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_high]}> Starter pack by {handle} @@ -522,7 +522,7 @@ export function ShowMoreActorsButton({ )} + style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_medium]}> {sanitizeHandle(profile.handle, '@')} ) @@ -613,7 +613,7 @@ export function ActorListItem({ numberOfLines={1} style={[ a.flex_shrink, - a.text_sm, + a.text_md, a.font_semi_bold, a.leading_snug, t.atoms.text, diff --git a/src/screens/Notifications/components/NotificationItem/Item/text.tsx b/src/screens/Notifications/components/NotificationItem/Item/text.tsx index 13a9a8663..def57a558 100644 --- a/src/screens/Notifications/components/NotificationItem/Item/text.tsx +++ b/src/screens/Notifications/components/NotificationItem/Item/text.tsx @@ -33,7 +33,7 @@ export function PrimaryText({ }) { const t = useTheme() return ( - + {children} ) @@ -56,7 +56,7 @@ export function SecondaryText({ + style={[a.text_md, a.leading_snug, t.atoms.text_contrast_medium, style]}> {children} ) @@ -67,7 +67,7 @@ export function SecondaryText({ */ export function Strong({children}: {children: React.ReactNode}) { return ( - + {children} ) @@ -108,7 +108,7 @@ export function Name({profile}: {profile: bsky.profile.AnyProfileView}) { disableUnderline emoji style={[ - a.text_sm, + a.text_md, a.leading_snug, a.font_semi_bold, t.atoms.text, @@ -138,7 +138,7 @@ export function Timestamp({date}: {date: string}) { {({timeElapsed}) => ( + style={[a.self_start, a.text_sm, t.atoms.text_contrast_low]}> {timeElapsed} )} diff --git a/src/screens/Notifications/components/NotificationItem/index.tsx b/src/screens/Notifications/components/NotificationItem/index.tsx index 394bd62fc..12bf27779 100644 --- a/src/screens/Notifications/components/NotificationItem/index.tsx +++ b/src/screens/Notifications/components/NotificationItem/index.tsx @@ -4,6 +4,9 @@ import { LikeNotification, LikeViaRepostNotification, MultiPostLikeNotification, + MultiPostLikeViaRepostNotification, + MultiPostRepostNotification, + MultiPostRepostViaRepostNotification, RepostNotification, RepostViaRepostNotification, SubscribedPostNotification, @@ -44,6 +47,14 @@ export function NotificationItem({ return case 'multiPostLike': return + case 'multiPostRepost': + return + case 'multiPostLikeViaRepost': + return + case 'multiPostRepostViaRepost': + return ( + + ) case 'repost': return case 'likeViaRepost': diff --git a/src/screens/Notifications/components/NotificationItem/kinds/aggregate.tsx b/src/screens/Notifications/components/NotificationItem/kinds/aggregate.tsx index 7b410991f..88d14d8e8 100644 --- a/src/screens/Notifications/components/NotificationItem/kinds/aggregate.tsx +++ b/src/screens/Notifications/components/NotificationItem/kinds/aggregate.tsx @@ -5,14 +5,14 @@ import {Plural, Trans, useLingui} from '@lingui/react/macro' import {makeCustomFeedLink} from '#/lib/routes/links' import {atoms as a, useTheme} from '#/alf' -import {BellPlus_Stroke2_Corner0_Rounded as BellPlusIcon} from '#/components/icons/Bell' import {type Props as SVGIconProps} from '#/components/icons/common' -import {Heart2_Filled_Stroke2_Corner0_Rounded as HeartIcon} from '#/components/icons/Heart2' import {LikeRepost_Stroke2_Corner2_Rounded as LikeRepostIcon} from '#/components/icons/LikeRepost' import { - Repost_Stroke2_Corner3_Rounded as RepostIcon, - RepostRepost_Stroke2_Corner2_Rounded as RepostRepostIcon, -} from '#/components/icons/Repost' + NotificationActivitySmall_Filled_Corner0_Rounded as ActivityIcon, + NotificationLikeSmall_Filled_Corner0_Rounded as HeartIcon, + NotificationRepostSmall_Filled_Corner0_Rounded as RepostIcon, +} from '#/components/icons/Notification' +import {RepostRepost_Stroke2_Corner2_Rounded as RepostRepostIcon} from '#/components/icons/Repost' import * as Item from '../Item' import {makeActivityListLink, makePostLink} from '../links' import {type NotificationOf} from '../types' @@ -277,19 +277,42 @@ export function RepostViaRepostNotification({ } /** - * One person liked several of the viewer's posts. The row and "View all" open - * the activity list with every liked post. + * Shared anatomy for one person liking or reposting several posts: their + * avatar, the primary sentence, a preview of the newest post, and a "View + * all" link. The row and the link open the activity list with every post. */ -export function MultiPostLikeNotification({ +function MultiPostRow({ notification, + icon, + tone, + label, + viewAllLabel, + children, }: { - notification: NotificationOf<'multiPostLike'> + notification: NotificationOf< + | 'multiPostLike' + | 'multiPostRepost' + | 'multiPostLikeViaRepost' + | 'multiPostRepostViaRepost' + > + icon: React.ComponentType + tone: Item.BadgeTone + /** + * Plain-text version of the primary sentence, for screen readers. + */ + label: string + /** + * Accessibility label for "View all", saying what "all" is. + */ + viewAllLabel: string + /** + * The primary sentence, as an `Item.PrimaryText`. + */ + children: React.ReactNode }) { const t = useTheme() - const {t: l} = useLingui() - const {actor, posts, count} = notification + const {actor, posts} = notification const [post] = posts - const name = Item.useDisplayName(actor) const href = makeActivityListLink(posts.map(p => p.uri)) const hasThumbnails = Item.getPostThumbnails(post.embed).length > 0 const mediaBlurred = Item.usePostMediaBlurred(post) @@ -298,22 +321,14 @@ export function MultiPostLikeNotification({ - + - - - liked {count} of your{' '} - - - + {children} - + {hasThumbnails && ( @@ -328,6 +343,136 @@ export function MultiPostLikeNotification({ ) } +/** + * One person liked several of the viewer's posts. + */ +export function MultiPostLikeNotification({ + notification, +}: { + notification: NotificationOf<'multiPostLike'> +}) { + const {t: l} = useLingui() + const {actor, count} = notification + const name = Item.useDisplayName(actor) + + return ( + + + + liked {count} of your{' '} + + + + + ) +} + +/** + * One person reposted several of the viewer's posts. + */ +export function MultiPostRepostNotification({ + notification, +}: { + notification: NotificationOf<'multiPostRepost'> +}) { + const {t: l} = useLingui() + const {actor, count} = notification + const name = Item.useDisplayName(actor) + + return ( + + + + reposted {count} of your{' '} + + + + + ) +} + +/** + * One person liked several posts via the viewer's reposts of them. The row + * previews and lists the original posts. + */ +export function MultiPostLikeViaRepostNotification({ + notification, +}: { + notification: NotificationOf<'multiPostLikeViaRepost'> +}) { + const {t: l} = useLingui() + const {actor, count} = notification + const name = Item.useDisplayName(actor) + + return ( + + + + liked {count} of your{' '} + + + + + ) +} + +/** + * One person reposted several posts via the viewer's reposts of them. The + * row previews and lists the original posts. + */ +export function MultiPostRepostViaRepostNotification({ + notification, +}: { + notification: NotificationOf<'multiPostRepostViaRepost'> +}) { + const {t: l} = useLingui() + const {actor, count} = notification + const name = Item.useDisplayName(actor) + + return ( + + + + reposted {count} of your{' '} + + + + + ) +} + /** * Someone, or a group of people, liked one of the viewer's custom feeds. */ @@ -431,7 +576,7 @@ export function SubscribedPostNotification({ : l`New ${plural(count, {one: 'post', other: 'posts'})} from ${name}` } testID={`notification-${notification.type}-${notification.id}`}> - + {others > 0 && ( diff --git a/src/screens/Notifications/components/NotificationItem/kinds/follower.tsx b/src/screens/Notifications/components/NotificationItem/kinds/follower.tsx index 4d45a2999..099dc9c7d 100644 --- a/src/screens/Notifications/components/NotificationItem/kinds/follower.tsx +++ b/src/screens/Notifications/components/NotificationItem/kinds/follower.tsx @@ -10,7 +10,7 @@ import {type NotificationView} from '#/state/queries/notifications/grouped/types import {unstableCacheProfileView} from '#/state/queries/unstable-profile-cache' import {PreviewableUserAvatar} from '#/view/com/util/UserAvatar' import {atoms as a, useBreakpoints, useTheme} from '#/alf' -import {PersonPlus_Filled_Stroke2_Corner0_Rounded as PersonPlusIcon} from '#/components/icons/Person' +import {NotificationFollowSmall_Filled_Corner0_Rounded as PersonPlusIcon} from '#/components/icons/Notification' import {ProfileBadges} from '#/components/ProfileBadges' import {Text} from '#/components/Typography' import type * as bsky from '#/types/bsky' @@ -106,7 +106,7 @@ export function FollowerNotification({ + style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_medium]}> {sanitizeHandle(profile.handle, '@')} ) @@ -135,7 +135,7 @@ export function FollowerNotification({ numberOfLines={1} style={[ a.flex_shrink, - a.text_sm, + a.text_md, a.font_semi_bold, a.leading_snug, t.atoms.text, @@ -165,7 +165,8 @@ function PlainAvatar({profile}: {profile: bsky.profile.AnyProfileView}) { return ( @@ -41,7 +43,7 @@ export function QuoteNotification({ return ( @@ -59,7 +61,7 @@ export function MentionNotification({ return ( diff --git a/src/screens/Notifications/components/NotificationItem/kinds/profile.tsx b/src/screens/Notifications/components/NotificationItem/kinds/profile.tsx index e51867409..96916c197 100644 --- a/src/screens/Notifications/components/NotificationItem/kinds/profile.tsx +++ b/src/screens/Notifications/components/NotificationItem/kinds/profile.tsx @@ -13,9 +13,11 @@ import {useFollowActorsQuery} from '#/state/queries/notifications/grouped' import {unstableCacheProfileView} from '#/state/queries/unstable-profile-cache' import {useSession} from '#/state/session' import {atoms as a} from '#/alf' -import {StarterPack_Stroke2_Corner0_Rounded as StarterPackIcon} from '#/components/icons/brands/StarterPack' -import {CheckThick_Stroke2_Corner0_Rounded as CheckIcon} from '#/components/icons/Check' -import {PersonPlus_Filled_Stroke2_Corner0_Rounded as PersonPlusIcon} from '#/components/icons/Person' +import { + NotificationFollowSmall_Filled_Corner0_Rounded as PersonPlusIcon, + NotificationStarterPackSmall_Filled_Corner0_Rounded as StarterPackIcon, + NotificationVerifiedSmall_Filled_Corner0_Rounded as CheckIcon, +} from '#/components/icons/Notification' import * as Toast from '#/components/Toast' import {useAnalytics} from '#/analytics' import type * as bsky from '#/types/bsky' @@ -70,7 +72,7 @@ function SingleFollowNotification({ testID={`notification-follow-${notification.id}`}> - + followed you diff --git a/src/state/queries/notifications/grouped/__fixtures__/index.ts b/src/state/queries/notifications/grouped/__fixtures__/index.ts index a61c7c367..20270cec0 100644 --- a/src/state/queries/notifications/grouped/__fixtures__/index.ts +++ b/src/state/queries/notifications/grouped/__fixtures__/index.ts @@ -16,10 +16,10 @@ import {type app} from '#/lexicons' type OutputBody = app.bsky.notification.getGroupedNotifications.$OutputBody type Group = app.bsky.notification.getGroupedNotifications.Group -type ProfileViewDetailed = app.bsky.actor.defs.ProfileViewDetailed +type ProfileViewBasic = app.bsky.actor.defs.ProfileViewBasic type PostView = app.bsky.feed.defs.PostView type GeneratorView = app.bsky.feed.defs.GeneratorView -type StarterPackView = app.bsky.graph.defs.StarterPackView +type StarterPackViewBasic = app.bsky.graph.defs.StarterPackViewBasic type BlockedPost = app.bsky.feed.defs.BlockedPost type NotFoundPost = app.bsky.feed.defs.NotFoundPost @@ -71,7 +71,6 @@ export function createGroupedNotificationsFixture( did: 'did:plc:danielleyuhan', handle: 'danielleyuhan.bsky.social', displayName: 'danielleyuhan', - description: 'Designer. Hiker. Collector of interesting rocks.', viewer: { following: followUri(VIEWER_DID, 'danielle'), followedBy: followUri('did:plc:danielleyuhan', 'tim'), @@ -81,7 +80,6 @@ export function createGroupedNotificationsFixture( did: 'did:plc:michaelblack', handle: 'michaelblack.bsky.social', displayName: 'Michael Black', - description: 'Amateur mycologist and professional coffee drinker', }) const darrin = profile({ did: 'did:plc:darrin', @@ -116,7 +114,6 @@ export function createGroupedNotificationsFixture( did: 'did:plc:marcus', handle: 'marcuswebb.com', displayName: 'Marcus Webb', - description: 'Writing about science, nature, and the spaces in between.', }) const priya = profile({ did: 'did:plc:priya', @@ -138,7 +135,6 @@ export function createGroupedNotificationsFixture( did: 'did:plc:sofia', handle: 'sofia.bsky.social', displayName: 'Sofia Alvarez', - description: 'Science communicator 🔬 she/her', viewer: {followedBy: followUri('did:plc:sofia', 'tim'), knownFollowers}, }) const jonas = profile({ @@ -257,6 +253,7 @@ export function createGroupedNotificationsFixture( */ const viaRepost: AtUriString = `at://${VIEWER_DID}/app.bsky.feed.repost/bronco` + const priyaViaRepost: AtUriString = `at://${VIEWER_DID}/app.bsky.feed.repost/priya` const broncoPost = post({ author: darrin, rkey: 'bronco', @@ -578,6 +575,45 @@ export function createGroupedNotificationsFixture( ], }, }, + { + id: 'multi-post-repost-aiko', + isRead: true, + indexedAt: ago(10 * HOUR), + count: 2, + kind: { + $type: `${$group}#multiPostRepostGroup`, + actor: aiko.did, + items: [{post: animalsPost.uri}, {post: fungusPost.uri}], + }, + }, + { + id: 'multi-post-like-via-repost-noah', + isRead: true, + indexedAt: ago(11 * HOUR), + count: 2, + kind: { + $type: `${$group}#multiPostLikeViaRepostGroup`, + actor: noah.did, + items: [ + {post: broncoPost.uri, viaRepost}, + {post: priyaPost.uri, viaRepost: priyaViaRepost}, + ], + }, + }, + { + id: 'multi-post-repost-via-repost-lena', + isRead: true, + indexedAt: ago(12 * HOUR), + count: 2, + kind: { + $type: `${$group}#multiPostRepostViaRepostGroup`, + actor: lena.did, + items: [ + {post: broncoPost.uri, viaRepost}, + {post: priyaPost.uri, viaRepost: priyaViaRepost}, + ], + }, + }, { id: 'subscribed-samuel', isRead: true, @@ -835,37 +871,30 @@ function profile({ did, handle, displayName, - description, viewer = {}, }: { did: DidString handle: HandleString displayName: string - description?: string - viewer?: ProfileViewDetailed['viewer'] -}): $Typed { + viewer?: ProfileViewBasic['viewer'] +}): $Typed { return { - $type: 'app.bsky.actor.defs#profileViewDetailed', + $type: 'app.bsky.actor.defs#profileViewBasic', did, handle, displayName, - description, avatar: undefined, labels: [], viewer, - followersCount: 412, - followsCount: 287, - postsCount: 1093, createdAt: '2023-05-02T17:24:11.000Z', - indexedAt: '2023-05-02T17:24:11.000Z', } } /** - * The basic view embedded in posts and packs. Left untyped so it also - * satisfies `ProfileView`, which a generator's `creator` requires. + * A profile without its `$type`, as embedded in posts and packs. Left untyped + * so it also satisfies `ProfileView`, which a generator's `creator` requires. */ -function basic(profile: ProfileViewDetailed) { +function basic(profile: ProfileViewBasic) { return { did: profile.did, handle: profile.handle, @@ -891,7 +920,7 @@ function post({ replyCount = 0, quoteCount = 0, }: { - author: ProfileViewDetailed + author: ProfileViewBasic rkey: string text: string indexedAt: DatetimeString @@ -1005,16 +1034,16 @@ function starterPack({ joinedWeekCount, joinedAllTimeCount, }: { - creator: ProfileViewDetailed + creator: ProfileViewBasic rkey: string name: string description: string indexedAt: DatetimeString joinedWeekCount: number joinedAllTimeCount: number -}): $Typed { +}): $Typed { return { - $type: 'app.bsky.graph.defs#starterPackView', + $type: 'app.bsky.graph.defs#starterPackViewBasic', uri: `at://${creator.did}/app.bsky.graph.starterpack/${rkey}`, cid: cid(`pack-${rkey}`), creator: basic(creator), diff --git a/src/state/queries/notifications/grouped/__tests__/follow-actors.test.ts b/src/state/queries/notifications/grouped/__tests__/follow-actors.test.ts index 1122303b7..f749f9ce6 100644 --- a/src/state/queries/notifications/grouped/__tests__/follow-actors.test.ts +++ b/src/state/queries/notifications/grouped/__tests__/follow-actors.test.ts @@ -72,7 +72,13 @@ function page(requested: DidString[], returned = requested): FollowActorsPage { ) } -function hideableOffense(actor: ProfileView): ProfileView { +/** + * Works on notification actors and on followers loaded with "Show more", + * which are basic and detailed views respectively. + */ +function hideableOffense< + T extends Pick, +>(actor: T): T { const label: com.atproto.label.defs.Label = { src: LABELER, uri: actor.did, diff --git a/src/state/queries/notifications/grouped/__tests__/hydrate.test.ts b/src/state/queries/notifications/grouped/__tests__/hydrate.test.ts index bbcc7e28e..82756c866 100644 --- a/src/state/queries/notifications/grouped/__tests__/hydrate.test.ts +++ b/src/state/queries/notifications/grouped/__tests__/hydrate.test.ts @@ -45,6 +45,10 @@ const MICHAEL: DidString = 'did:plc:michaelblack' * Things that don't. */ const MISSING_POST: AtUriString = 'at://did:plc:nobody/app.bsky.feed.post/gone' +/** + * A repost by the viewer. Nothing resolves it, so it needn't exist. + */ +const VIA_REPOST: AtUriString = `at://${VIEWER_DID}/app.bsky.feed.repost/x` const MISSING_PACK: AtUriString = 'at://did:plc:nobody/app.bsky.graph.starterpack/gone' const GHOST: DidString = 'did:plc:ghost' @@ -52,6 +56,9 @@ const GHOST: DidString = 'did:plc:ghost' const ALL_TYPES: NotificationViewType[] = [ 'like', 'multiPostLike', + 'multiPostRepost', + 'multiPostLikeViaRepost', + 'multiPostRepostViaRepost', 'repost', 'likeViaRepost', 'repostViaRepost', @@ -109,7 +116,7 @@ function hydrateKind(kind: Kind): NotificationView | undefined { function related(res: OutputBody, key: string): unknown { const view = res.relatedViews?.find(v => { const candidate = v as {$type: string; did?: string; uri?: string} - return candidate.$type === 'app.bsky.actor.defs#profileViewDetailed' + return candidate.$type === 'app.bsky.actor.defs#profileViewBasic' ? candidate.did === key : candidate.uri === key }) @@ -243,6 +250,30 @@ describe('hydratePage', () => { } }) + it('maps multi-post reposts and likes and reposts via reposts', () => { + const {res, page} = setup() + const reposts = get(page, 'multi-post-repost-aiko', 'multiPostRepost') + expect(reposts.actor).toBe(related(res, 'did:plc:aiko')) + expect(reposts.posts).toHaveLength(2) + const likesVia = get( + page, + 'multi-post-like-via-repost-noah', + 'multiPostLikeViaRepost', + ) + expect(likesVia.actor).toBe(related(res, 'did:plc:noah')) + const repostsVia = get( + page, + 'multi-post-repost-via-repost-lena', + 'multiPostRepostViaRepost', + ) + expect(repostsVia.actor).toBe(related(res, 'did:plc:lena')) + for (const multi of [reposts, likesVia, repostsVia]) { + for (const post of multi.posts) { + expect(post).toBe(related(res, post.uri)) + } + } + }) + it('maps follows, with and without a starter pack', () => { const {res, page} = setup() const many = get(page, 'follow-many', 'follow') @@ -546,7 +577,7 @@ describe('hydratePage', () => { it('removes the viewer even when their profile is in relatedViews', () => { const res = createGroupedNotificationsFixture(NOW) const viewer = { - $type: 'app.bsky.actor.defs#profileViewDetailed' as const, + $type: 'app.bsky.actor.defs#profileViewBasic' as const, did: VIEWER_DID, handle: 'tim.bsky.team' as const, } @@ -620,6 +651,36 @@ describe('hydratePage', () => { items: [{post: FUNGUS_POST}, {post: PLANTS_POST}], }), ], + [ + 'multiPostRepost', + actor => ({ + $type: `${NS}#multiPostRepostGroup`, + actor, + items: [{post: FUNGUS_POST}, {post: PLANTS_POST}], + }), + ], + [ + 'multiPostLikeViaRepost', + actor => ({ + $type: `${NS}#multiPostLikeViaRepostGroup`, + actor, + items: [ + {post: FUNGUS_POST, viaRepost: VIA_REPOST}, + {post: PLANTS_POST, viaRepost: VIA_REPOST}, + ], + }), + ], + [ + 'multiPostRepostViaRepost', + actor => ({ + $type: `${NS}#multiPostRepostViaRepostGroup`, + actor, + items: [ + {post: FUNGUS_POST, viaRepost: VIA_REPOST}, + {post: PLANTS_POST, viaRepost: VIA_REPOST}, + ], + }), + ], ] it.each(singleActorKinds)( diff --git a/src/state/queries/notifications/grouped/hydrate.ts b/src/state/queries/notifications/grouped/hydrate.ts index 49e4c78c1..43f998eea 100644 --- a/src/state/queries/notifications/grouped/hydrate.ts +++ b/src/state/queries/notifications/grouped/hydrate.ts @@ -12,10 +12,10 @@ import * as bsky from '#/types/bsky' type OutputBody = app.bsky.notification.getGroupedNotifications.$OutputBody type Group = app.bsky.notification.getGroupedNotifications.Group -type ProfileView = app.bsky.actor.defs.ProfileViewDetailed +type ProfileView = app.bsky.actor.defs.ProfileViewBasic type PostView = app.bsky.feed.defs.PostView type GeneratorView = app.bsky.feed.defs.GeneratorView -type StarterPackView = app.bsky.graph.defs.StarterPackView +type StarterPackView = app.bsky.graph.defs.StarterPackViewBasic const defs = app.bsky.notification.getGroupedNotifications @@ -80,7 +80,7 @@ function createContext( starterPacks: new Map(), } for (const view of relatedViews ?? []) { - if (bsky.isType(app.bsky.actor.defs.profileViewDetailed, view)) { + if (bsky.isType(app.bsky.actor.defs.profileViewBasic, view)) { ctx.profiles.set(view.did, view) } else if (bsky.isType(app.bsky.feed.defs.postView, view)) { ctx.posts.set(view.uri, {type: 'post', post: view}) @@ -90,7 +90,7 @@ function createContext( ctx.posts.set(view.uri, {type: 'notFound'}) } else if (bsky.isType(app.bsky.feed.defs.generatorView, view)) { ctx.generators.set(view.uri, view) - } else if (bsky.isType(app.bsky.graph.defs.starterPackView, view)) { + } else if (bsky.isType(app.bsky.graph.defs.starterPackViewBasic, view)) { ctx.starterPacks.set(view.uri, view) } } @@ -150,15 +150,23 @@ function hydrateGroup( } if (bsky.isType(defs.multiPostLikeGroup, kind)) { - const actor = resolveActor(kind.actor, ctx) - const posts = nonEmpty( - kind.items.flatMap(item => { - const post = resolvePost(item.post, ctx) - return post ? [post] : [] - }), - ) - if (!actor || !posts) return - return {...base, type: 'multiPostLike', actor, posts} + const multi = resolveMultiPost(kind, ctx) + return multi && {...base, type: 'multiPostLike', ...multi} + } + + if (bsky.isType(defs.multiPostRepostGroup, kind)) { + const multi = resolveMultiPost(kind, ctx) + return multi && {...base, type: 'multiPostRepost', ...multi} + } + + if (bsky.isType(defs.multiPostLikeViaRepostGroup, kind)) { + const multi = resolveMultiPost(kind, ctx) + return multi && {...base, type: 'multiPostLikeViaRepost', ...multi} + } + + if (bsky.isType(defs.multiPostRepostViaRepostGroup, kind)) { + const multi = resolveMultiPost(kind, ctx) + return multi && {...base, type: 'multiPostRepostViaRepost', ...multi} } if (bsky.isType(defs.followGroup, kind)) { @@ -279,6 +287,25 @@ function resolveActor(did: string, ctx: Context): ProfileView | undefined { return ctx.profiles.get(did) } +/** + * Resolves a group of one actor's likes or reposts of several posts, skipping + * posts that don't resolve. Undefined if the actor or every post is missing. + */ +function resolveMultiPost( + kind: {actor: string; items: {post: string}[]}, + ctx: Context, +): {actor: ProfileView; posts: NonEmptyArray} | undefined { + const actor = resolveActor(kind.actor, ctx) + const posts = nonEmpty( + kind.items.flatMap(item => { + const post = resolvePost(item.post, ctx) + return post ? [post] : [] + }), + ) + if (!actor || !posts) return + return {actor, posts} +} + /** * Resolves each item's actor, skipping unresolved ones and duplicates. The * first resolved actor is the group's primary actor. diff --git a/src/state/queries/notifications/grouped/index.ts b/src/state/queries/notifications/grouped/index.ts index 2a8054c66..6c4401a64 100644 --- a/src/state/queries/notifications/grouped/index.ts +++ b/src/state/queries/notifications/grouped/index.ts @@ -44,7 +44,7 @@ export type { ParentPost, } from '#/state/queries/notifications/grouped/types' -type ProfileView = app.bsky.actor.defs.ProfileViewDetailed +type ProfileView = app.bsky.actor.defs.ProfileViewBasic type PostView = app.bsky.feed.defs.PostView const PAGE_SIZE = 30 @@ -309,6 +309,9 @@ function* postsInNotification( } break case 'multiPostLike': + case 'multiPostRepost': + case 'multiPostLikeViaRepost': + case 'multiPostRepostViaRepost': yield* notification.posts break case 'subscribedPost': @@ -335,6 +338,9 @@ function* actorsInNotification( yield* notification.actors break case 'multiPostLike': + case 'multiPostRepost': + case 'multiPostLikeViaRepost': + case 'multiPostRepostViaRepost': case 'followBack': case 'verified': case 'unverified': diff --git a/src/state/queries/notifications/grouped/moderate.ts b/src/state/queries/notifications/grouped/moderate.ts index ea6d1428e..1e6bc950c 100644 --- a/src/state/queries/notifications/grouped/moderate.ts +++ b/src/state/queries/notifications/grouped/moderate.ts @@ -13,7 +13,12 @@ import { import {app} from '#/lexicons' import * as bsky from '#/types/bsky' -type ProfileView = app.bsky.actor.defs.ProfileViewDetailed +/** + * Notification actors are basic views, but followers loaded with "Show more" + * come from `getProfiles`, which returns detailed ones. + */ +type ProfileView = + app.bsky.actor.defs.ProfileViewBasic | app.bsky.actor.defs.ProfileViewDetailed type PostView = app.bsky.feed.defs.PostView /** @@ -81,6 +86,9 @@ export function moderateNotification( } } case 'multiPostLike': + case 'multiPostRepost': + case 'multiPostLikeViaRepost': + case 'multiPostRepostViaRepost': case 'followBack': case 'verified': case 'unverified': diff --git a/src/state/queries/notifications/grouped/types.ts b/src/state/queries/notifications/grouped/types.ts index c5e6c195c..cc7b645bb 100644 --- a/src/state/queries/notifications/grouped/types.ts +++ b/src/state/queries/notifications/grouped/types.ts @@ -8,10 +8,10 @@ import {type app} from '#/lexicons' export type GroupedNotificationsFeed = 'all' | 'people-i-follow' | 'conversations' | 'followers' | 'activity' -type ProfileView = app.bsky.actor.defs.ProfileViewDetailed +type ProfileView = app.bsky.actor.defs.ProfileViewBasic type PostView = app.bsky.feed.defs.PostView type GeneratorView = app.bsky.feed.defs.GeneratorView -type StarterPackView = app.bsky.graph.defs.StarterPackView +type StarterPackView = app.bsky.graph.defs.StarterPackViewBasic /** * Guarantees a primary actor, so rows never have to handle an empty list. @@ -58,6 +58,29 @@ export type NotificationView = actor: ProfileView posts: NonEmptyArray }) + | (Base & { + type: 'multiPostRepost' + actor: ProfileView + posts: NonEmptyArray + }) + | (Base & { + /** + * Likes of several posts via the viewer's reposts of them. `posts` are + * the original posts. + */ + type: 'multiPostLikeViaRepost' + actor: ProfileView + posts: NonEmptyArray + }) + | (Base & { + /** + * Reposts of several posts via the viewer's reposts of them. `posts` + * are the original posts. + */ + type: 'multiPostRepostViaRepost' + actor: ProfileView + posts: NonEmptyArray + }) | (Base & { type: 'repost' post: PostView diff --git a/src/view/screens/DebugMod/GroupedNotifications.tsx b/src/view/screens/DebugMod/GroupedNotifications.tsx index 24370ef34..f8c5412b4 100644 --- a/src/view/screens/DebugMod/GroupedNotifications.tsx +++ b/src/view/screens/DebugMod/GroupedNotifications.tsx @@ -15,7 +15,7 @@ import {P, Text} from '#/components/Typography' import {type app, type com} from '#/lexicons' import {mock} from './mock' -type ProfileView = app.bsky.actor.defs.ProfileViewDetailed +type ProfileView = app.bsky.actor.defs.ProfileViewBasic type PostView = app.bsky.feed.defs.PostView type Label = com.atproto.label.defs.Label @@ -99,7 +99,7 @@ export function GroupedNotifications({ } const notifications = createMockNotifications({ - target: toProfileViewDetailed(profile), + target: profile, targetPost: post, viewer, groupPosition: groupPosition[0] as GroupPosition, @@ -254,8 +254,8 @@ function createMockNotifications({ ) => Label[] | undefined }): MockNotification[] { const indexedAt = new Date().toISOString() - const carolActor = toProfileViewDetailed(carol) - const daveActor = toProfileViewDetailed(dave) + const carolActor = carol + const daveActor = dave const group: NonEmptyArray = groupPosition === 'first' ? [target, carolActor, daveActor] @@ -348,7 +348,7 @@ function createMockNotifications({ creator: viewer, displayName: 'Your custom feed', }) - const starterPack = mock.starterPackView({ + const starterPack = mock.starterPackViewBasic({ creator: viewer, name: 'Your starter pack', }) @@ -426,6 +426,36 @@ function createMockNotifications({ posts: [likedPost, otherLikedPost], }, }, + { + title: 'Multi-post repost', + subtitle: 'one actor, two posts', + notification: { + ...base('multi-post-repost', 2), + type: 'multiPostRepost', + actor: target, + posts: [likedPost, otherLikedPost], + }, + }, + { + title: 'Multi-post like via repost', + subtitle: 'one actor, two posts', + notification: { + ...base('multi-post-like-via-repost', 2), + type: 'multiPostLikeViaRepost', + actor: target, + posts: [repostedPost, otherLikedPost], + }, + }, + { + title: 'Multi-post repost via repost', + subtitle: 'one actor, two posts', + notification: { + ...base('multi-post-repost-via-repost', 2), + type: 'multiPostRepostViaRepost', + actor: target, + posts: [repostedPost, otherLikedPost], + }, + }, { title: 'Feed like', subtitle: 'multiple actors', @@ -550,12 +580,6 @@ function createMockNotifications({ ] } -function toProfileViewDetailed( - profile: app.bsky.actor.defs.ProfileViewBasic, -): ProfileView { - return {...profile, $type: 'app.bsky.actor.defs#profileViewDetailed'} -} - function bystander(handle: string, displayName: string) { return mock.profileViewBasic({ handle, diff --git a/src/view/screens/DebugMod/mock.ts b/src/view/screens/DebugMod/mock.ts index 8d2ae5191..42e60447b 100644 --- a/src/view/screens/DebugMod/mock.ts +++ b/src/view/screens/DebugMod/mock.ts @@ -231,16 +231,16 @@ export const mock = { new Date().toISOString() as app.bsky.feed.defs.GeneratorView['indexedAt'], } }, - starterPackView({ + starterPackViewBasic({ creator, name, }: { creator: app.bsky.actor.defs.ProfileViewBasic name: string - }): app.bsky.graph.defs.StarterPackView { + }): app.bsky.graph.defs.StarterPackViewBasic { const createdAt = new Date().toISOString() return { - $type: 'app.bsky.graph.defs#starterPackView', + $type: 'app.bsky.graph.defs#starterPackViewBasic', uri: `at://${creator.did}/app.bsky.graph.starterpack/fake`, cid: FAKE_CID, creator, @@ -250,7 +250,8 @@ export const mock = { list: `at://${creator.did}/app.bsky.graph.list/fake`, createdAt, }, - indexedAt: createdAt as app.bsky.graph.defs.StarterPackView['indexedAt'], + indexedAt: + createdAt as app.bsky.graph.defs.StarterPackViewBasic['indexedAt'], } }, label({ -- knotmirror 0.0.1