π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update space activity grouping
Anand Baburajana3616164d1de
diff --git a/web/apps/space/src/screens/MessagesScreen.tsx b/web/apps/space/src/screens/MessagesScreen.tsxindex 792663f2cd..f51418f21e 100644--- a/web/apps/space/src/screens/MessagesScreen.tsx+++ b/web/apps/space/src/screens/MessagesScreen.tsx@@ -44,6 +44,7 @@ const threadBottomThresholdPx = 96;const messageGroupTimeThresholdMs = 10 * 60 * 1000;const messageLongPressMs = 520;const messageLongPressMoveTolerancePx = 10;+const dayMs = 24 * 60 * 60 * 1000;interface MessagesScreenProps {conversations: SpaceMessageConversation[];@@ -78,6 +79,11 @@ interface MessageContextMenuState {message: SpaceMessage;}+interface ConversationSection {+ items: SpaceMessageConversation[];+ title: string;+}+const microsForTimestamp = (timestampMs: number) => timestampMs * 1000;const resizeComposer = (input: HTMLTextAreaElement | null) => {@@ -296,6 +302,65 @@ const ConversationPreviewLine: React.FC<{const conversationId = (conversation: SpaceMessageConversation) =>conversation.friend.spaceId ?? conversation.friend.id;+const conversationTimeSections = (+ conversations: SpaceMessageConversation[],+) => {+ const now = Date.now();+ const today = new Date(now);+ const startOfTodayMs = new Date(+ today.getFullYear(),+ today.getMonth(),+ today.getDate(),+ ).getTime();+ const startOfYesterdayMs = new Date(+ today.getFullYear(),+ today.getMonth(),+ today.getDate() - 1,+ ).getTime();+ const sections: ConversationSection[] = [+ { title: "New", items: [] },+ { title: "Today", items: [] },+ { title: "Yesterday", items: [] },+ { title: "Last 7 days", items: [] },+ { title: "Last 30 days", items: [] },+ { title: "Older", items: [] },+ { title: "No messages", items: [] },+ ];++ for (const conversation of conversations) {+ if (conversation.unread) {+ sections[0]!.items.push(conversation);+ continue;+ }++ const activity = conversation.latestActivity;+ if (!activity) {+ sections[6]!.items.push(conversation);+ continue;+ }+ if (activity.createdAtMs >= startOfTodayMs) {+ sections[1]!.items.push(conversation);+ continue;+ }+ if (activity.createdAtMs >= startOfYesterdayMs) {+ sections[2]!.items.push(conversation);+ continue;+ }++ const ageMs = Math.max(0, now - activity.createdAtMs);+ if (ageMs <= 7 * dayMs) {+ sections[3]!.items.push(conversation);+ continue;+ }+ if (ageMs <= 30 * dayMs) {+ sections[4]!.items.push(conversation);+ continue;+ }+ sections[5]!.items.push(conversation);+ }+ return sections;+};+const conversationUnreadLabel = (count: number) =>count > 99 ? "99+" : String(count);@@ -473,6 +538,44 @@ const ConversationListItem: React.FC<{);};+const ConversationSection: React.FC<{+ onOpenThread: (conversation: SpaceMessageConversation) => void;+ profile: SetupProfile;+ section: ConversationSection;+}> = ({ onOpenThread, profile, section }) => {+ if (section.items.length == 0) return null;++ return (+ <Box component="section" sx={{ mb: "10px" }}>+ <Box+ component="h2"+ sx={{+ color: textSecondary,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 13,+ fontWeight: 700,+ lineHeight: "18px",+ m: 0,+ pb: "4px",+ pt: "12px",+ }}+ >+ {section.title}+ </Box>+ <Box component="ul" sx={{ listStyle: "none", m: 0, p: 0 }}>+ {section.items.map((conversation) => (+ <ConversationListItem+ key={conversationId(conversation)}+ conversation={conversation}+ onOpenThread={onOpenThread}+ profile={profile}+ />+ ))}+ </Box>+ </Box>+ );+};+const sameMessageSender = (first: SpaceMessage | undefined,second: SpaceMessage | undefined,@@ -1132,6 +1235,10 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({: "";const showInviteEmptyState =friendsCount == 0 && Boolean(onShareProfileLink);+ const conversationSections = React.useMemo(+ () => conversationTimeSections(conversations),+ [conversations],+ );const messageByID = React.useMemo(() => new Map(messages.map((message) => [message.id, message])),[messages],@@ -2124,12 +2231,12 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({p: "6px 16px 28px",}}>- {conversations.map((conversation) => (- <ConversationListItem- key={conversationId(conversation)}- conversation={conversation}+ {conversationSections.map((section) => (+ <ConversationSection+ key={section.title}onOpenThread={onOpenThread}profile={profile}+ section={section}/>))}</Box>diff --git a/web/apps/space/src/screens/NotificationsScreen.tsx b/web/apps/space/src/screens/NotificationsScreen.tsxindex fe3a02c1ad..dd5e83093c 100644--- a/web/apps/space/src/screens/NotificationsScreen.tsx+++ b/web/apps/space/src/screens/NotificationsScreen.tsx@@ -73,25 +73,20 @@ const PostLikeText: React.FC<{ actors: SpaceNotification["actor"][] }> = ({</>);}- if (actors.length == 3) {- return (- <>- <ActorName actor={actors[0]!} />,{" "}- <ActorName actor={actors[1]!} /> and{" "}- <ActorName actor={actors[2]!} /> liked your post.- </>- );- }-return (<>- <ActorName actor={actors[0]!} />, <ActorName actor={actors[1]!} />{" "}- and {actors.length == 4 ? "2" : "2+"} others liked your post.+ <ActorName actor={actors[0]!} /> and{" "}+ <Box component="span" sx={{ fontWeight: 700 }}>+ {actors.length - 1} others+ </Box>{" "}+ liked your post.</>);};-const NotificationText: React.FC<{ group: NotificationGroup }> = ({ group }) => {+const NotificationText: React.FC<{ group: NotificationGroup }> = ({+ group,+}) => {const actor = group.actors[0]!;switch (group.type) {case "friend_add":@@ -113,42 +108,65 @@ const NotificationText: React.FC<{ group: NotificationGroup }> = ({ group }) =>const AvatarStack: React.FC<{ actors: SpaceNotification["actor"][] }> = ({actors,-}) => (- <Box sx={{ flexShrink: 0, height: 44, position: "relative", width: 44 }}>- {actors.slice(0, 3).map((actor, index) => (- <Box- key={`${actor.spaceId ?? actor.id}-${index}`}- sx={{- bgcolor: avatarSkeletonBackground,- border: `2px solid ${notificationsBackground}`,- borderRadius: "50%",- height: actors.length == 1 ? 44 : 30,- left: actors.length == 1 ? 0 : index * 6,- overflow: "hidden",- position: "absolute",- top: actors.length == 1 ? 0 : index * 5,- width: actors.length == 1 ? 44 : 30,- zIndex: 3 - index,- }}- >- {actor.avatarUrl && (+}) => {+ const isPair = actors.length == 2;+ const displayedActors = isPair+ ? [actors[1]!, actors[0]!]+ : actors.slice(0, 3);+ const stackSize = isPair ? 48 : 44;++ return (+ <Box+ sx={{+ flexShrink: 0,+ height: stackSize,+ position: "relative",+ width: stackSize,+ }}+ >+ {displayedActors.map((actor, index) => {+ const isSingle = actors.length == 1;+ const avatarSize = isSingle ? 44 : isPair ? 34 : 30;+ const offset = isPair ? (index == 0 ? 0 : 12) : index * 6;+ const top = isPair ? (index == 0 ? 0 : 12) : index * 5;+ const zIndex = isPair ? index + 1 : 3 - index;++ return (<Box- component="img"- alt=""- src={actor.avatarUrl}+ key={`${actor.spaceId ?? actor.id}-${index}`}sx={{- display: "block",- height: "100%",- objectFit: "cover",- objectPosition: "center",- width: "100%",+ bgcolor: avatarSkeletonBackground,+ border: `2px solid ${notificationsBackground}`,+ borderRadius: "50%",+ height: avatarSize,+ left: isSingle ? 0 : offset,+ overflow: "hidden",+ position: "absolute",+ top: isSingle ? 0 : top,+ width: avatarSize,+ zIndex,}}- />- )}- </Box>- ))}- </Box>-);+ >+ {actor.avatarUrl && (+ <Box+ component="img"+ alt=""+ src={actor.avatarUrl}+ sx={{+ display: "block",+ height: "100%",+ objectFit: "cover",+ objectPosition: "center",+ width: "100%",+ }}+ />+ )}+ </Box>+ );+ })}+ </Box>+ );+};const timeSections = (notifications: SpaceNotification[]) => {const now = Date.now();@@ -209,7 +227,11 @@ const groupSectionNotifications = (items: SpaceNotification[]) => {: item.id;const existing = groups.get(key);if (existing) {- existing.actors.push(item.actor);+ if (item.createdAtMs > existing.createdAtMs) {+ existing.actors.unshift(item.actor);+ } else {+ existing.actors.push(item.actor);+ }existing.createdAtMs = Math.max(existing.createdAtMs,item.createdAtMs,@@ -232,6 +254,11 @@ const NotificationRow: React.FC<{onOpenFriendMessages?: (spaceId: string) => void;}> = ({ group, onOpenFriendMessages }) => {const postImageUrl = group.post?.imageUrl;+ const avatarActors =+ group.type == "post_like" && group.actors.length > 2+ ? group.actors.slice(0, 1)+ : group.actors;+ const avatarColumnWidth = avatarActors.length == 2 ? 52 : 44;const friendActivityActor =group.type == "post_like" ? undefined : group.actors[0];const friendActivitySpaceId = friendActivityActor@@ -263,8 +290,8 @@ const NotificationRow: React.FC<{display: "grid",gap: "10px",gridTemplateColumns: postImageUrl- ? "44px minmax(0, 1fr) 44px"- : "44px minmax(0, 1fr)",+ ? `${avatarColumnWidth}px minmax(0, 1fr) 44px`+ : `${avatarColumnWidth}px minmax(0, 1fr)`,minHeight: 64,p: "8px 0",textAlign: "left",@@ -276,7 +303,7 @@ const NotificationRow: React.FC<{"&:hover": { bgcolor: rowHover },}}>- <AvatarStack actors={group.actors} />+ <AvatarStack actors={avatarActors} /><Box sx={{ minWidth: 0 }}><Boxcomponent="p"