Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Rename space notifications to messages

Anand Baburajan234d0c37979e
diff --git a/web/apps/space/src/components/SpacePageMeta.tsx b/web/apps/space/src/components/SpacePageMeta.tsx
index a29673f3cd..823befc40f 100644
--- a/web/apps/space/src/components/SpacePageMeta.tsx
+++ b/web/apps/space/src/components/SpacePageMeta.tsx
@@ -4,10 +4,15 @@ import { onboardingDescription } from "screens/OnboardingScreen";
interface SpacePageMetaProps {
themeColor: string;
+ title?: string;
}
-export const SpacePageMeta: React.FC<SpacePageMetaProps> = ({ themeColor }) => (
+export const SpacePageMeta: React.FC<SpacePageMetaProps> = ({
+ themeColor,
+ title,
+}) => (
<Head>
+ {title && <title>{title}</title>}
<meta name="theme-color" content={themeColor} />
<meta name="robots" content="noindex,nofollow" />
<meta name="description" content={onboardingDescription} />
diff --git a/web/apps/space/src/pages/app/index.tsx b/web/apps/space/src/pages/app/index.tsx
index 5ab46aed97..cb7cc3629e 100644
--- a/web/apps/space/src/pages/app/index.tsx
+++ b/web/apps/space/src/pages/app/index.tsx
@@ -32,8 +32,7 @@ const Page: React.FC = () => {
} = useSpaceAppState();
const [addedFriendToastName, setAddedFriendToastName] = useState<string>();
const [feedItems, setFeedItems] = useState<SpacePost[]>([]);
- const [hasUnreadNotifications, setHasUnreadNotifications] =
- useState<boolean>();
+ const [hasUnreadMessages, setHasUnreadMessages] = useState<boolean>();
const [isFeedLoading, setIsFeedLoading] = useState(true);
const closeAddedFriendToast = React.useCallback(
() => setAddedFriendToastName(undefined),
@@ -62,13 +61,13 @@ const Page: React.FC = () => {
const spaceId = profile?.spaceId;
if (!spaceId) {
- setHasUnreadNotifications(false);
+ setHasUnreadMessages(false);
setIsFeedLoading(false);
return;
}
let cancelled = false;
- setHasUnreadNotifications(undefined);
+ setHasUnreadMessages(undefined);
setIsFeedLoading(true);
void Promise.all([
loadCurrentFeedPage(),
@@ -78,7 +77,7 @@ const Page: React.FC = () => {
.then(([feed, unreadStatus, nextFriends]) => {
if (cancelled) return;
setFeedItems(feed.items);
- setHasUnreadNotifications(unreadStatus.notificationsUnread);
+ setHasUnreadMessages(unreadStatus.messagesUnread);
setFriends(nextFriends);
const latestFeedPost = feed.items[0];
if (latestFeedPost) {
@@ -116,7 +115,7 @@ const Page: React.FC = () => {
feedItems={feedItems}
friendsCount={friends.length}
addedFriendToastName={addedFriendToastName}
- hasUnreadNotifications={hasUnreadNotifications}
+ hasUnreadMessages={hasUnreadMessages}
isFeedLoading={isFeedLoading}
profile={profile}
onAddedFriendToastClose={closeAddedFriendToast}
@@ -150,9 +149,7 @@ const Page: React.FC = () => {
onOpenFriend={(friendID) =>
void router.push(spaceRoutes.friend(friendID))
}
- onOpenNotifications={() =>
- void router.push(spaceRoutes.notifications)
- }
+ onOpenMessages={() => void router.push(spaceRoutes.messages)}
onOpenProfile={() => void router.push(spaceRoutes.profile)}
onLoadPostLikers={loadCurrentPostLikers}
onReplyToPost={replyToCurrentPost}
diff --git a/web/apps/space/src/pages/app/notifications.tsx b/web/apps/space/src/pages/app/messages.tsx
similarity index 95%
rename from web/apps/space/src/pages/app/notifications.tsx
rename to web/apps/space/src/pages/app/messages.tsx
index a4b624ed94..41e28cc514 100644
--- a/web/apps/space/src/pages/app/notifications.tsx
+++ b/web/apps/space/src/pages/app/messages.tsx
@@ -8,7 +8,7 @@ import {
loadCurrentMessageConversations,
loadCurrentMessageThread,
loadCurrentSpaceFriends,
- markCurrentNotificationsRead,
+ markCurrentMessagesRead,
replyToCurrentMessage,
sendCurrentMessage,
setCurrentMessageLiked,
@@ -82,10 +82,10 @@ const Page: React.FC = () => {
if (unreadConversationIds.length == 0) return;
void Promise.all(
unreadConversationIds.map((friendSpaceId) =>
- markCurrentNotificationsRead(friendSpaceId),
+ markCurrentMessagesRead(friendSpaceId),
),
).catch((error: unknown) =>
- console.warn("Failed to mark notifications read", error),
+ console.warn("Failed to mark messages read", error),
);
})
.catch((error: unknown) =>
@@ -110,10 +110,10 @@ const Page: React.FC = () => {
: currentConversation,
),
);
- void markCurrentNotificationsRead(friendSpaceId).catch(
+ void markCurrentMessagesRead(friendSpaceId).catch(
(error: unknown) =>
console.warn(
- "Failed to mark notification conversation read",
+ "Failed to mark message conversation read",
error,
),
);
@@ -198,7 +198,10 @@ const Page: React.FC = () => {
return (
<>
- <SpacePageMeta themeColor={messagesBackground} />
+ <SpacePageMeta
+ themeColor={messagesBackground}
+ title="Messages | Ente Space"
+ />
<MessagesScreen
conversations={conversations}
isConversationsLoading={isConversationsLoading}
diff --git a/web/apps/space/src/screens/HomeScreen.tsx b/web/apps/space/src/screens/HomeScreen.tsx
index bbb4ec1a3b..a6e729fbf4 100644
--- a/web/apps/space/src/screens/HomeScreen.tsx
+++ b/web/apps/space/src/screens/HomeScreen.tsx
@@ -90,7 +90,7 @@ interface HomeScreenProps {
addedFriendToastName?: string;
feedItems: SpacePost[];
friendsCount: number;
- hasUnreadNotifications?: boolean;
+ hasUnreadMessages?: boolean;
isFeedLoading?: boolean;
onAddedFriendToastClose?: () => void;
onCreatePost?: (
@@ -99,7 +99,7 @@ interface HomeScreenProps {
) => Promise<void>;
onDeletePost?: (postId: number) => Promise<void> | void;
onOpenFriend?: (friendID: string) => void;
- onOpenNotifications?: () => void;
+ onOpenMessages?: () => void;
onOpenProfile?: () => void;
onLoadPostLikers?: (postId: number) => Promise<SpaceLiker[]>;
onReplyToPost?: (postId: number, text: string) => Promise<void>;
@@ -820,14 +820,14 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
addedFriendToastName,
feedItems,
friendsCount,
- hasUnreadNotifications,
+ hasUnreadMessages,
isFeedLoading = false,
onAddedFriendToastClose,
onCreatePost,
onDeletePost,
onLoadPostLikers,
onOpenFriend,
- onOpenNotifications,
+ onOpenMessages,
onOpenProfile,
onReplyToPost,
onSetPostLiked,
@@ -849,7 +849,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
const hasFeedItems = feedItems.length > 0;
const isEmptyFeedLoading = !hasFeedItems && isFeedLoading;
const showFeedCards = hasFeedItems || isEmptyFeedLoading;
- const showUnreadIndicator = hasUnreadNotifications === true;
+ const showUnreadIndicator = hasUnreadMessages === true;
const emptyFeedMessage =
friendsCount == 0
? "When you add friends, their posts will appear here."
@@ -1109,10 +1109,10 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
type="button"
aria-label={
showUnreadIndicator
- ? "Open notifications with unread activity"
- : "Open notifications"
+ ? "Open messages with unread activity"
+ : "Open messages"
}
- onClick={onOpenNotifications}
+ onClick={onOpenMessages}
sx={{
appearance: "none",
alignItems: "center",
@@ -1120,9 +1120,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({
border: 0,
boxSizing: "border-box",
color: textBase,
- cursor: onOpenNotifications
- ? "pointer"
- : "default",
+ cursor: onOpenMessages ? "pointer" : "default",
display: "flex",
fontSize: 0,
height: headerActionSize,
diff --git a/web/apps/space/src/screens/MessagesScreen.tsx b/web/apps/space/src/screens/MessagesScreen.tsx
index 8c8b13c6b5..a39ca2695e 100644
--- a/web/apps/space/src/screens/MessagesScreen.tsx
+++ b/web/apps/space/src/screens/MessagesScreen.tsx
@@ -309,7 +309,7 @@ const conversationId = (conversation: SpaceMessageConversation) =>
const dayMs = 24 * 60 * 60 * 1000;
-const NotificationListItem: React.FC<{
+const ConversationListItem: React.FC<{
conversation: SpaceMessageConversation;
onOpenThread: (conversation: SpaceMessageConversation) => void;
profile: SetupProfile;
@@ -439,12 +439,12 @@ const NotificationListItem: React.FC<{
);
};
-interface NotificationSectionItem {
+interface ConversationSectionItem {
conversations: SpaceMessageConversation[];
title: string;
}
-const NotificationSection: React.FC<{
+const ConversationSection: React.FC<{
conversations: SpaceMessageConversation[];
onOpenThread: (conversation: SpaceMessageConversation) => void;
profile: SetupProfile;
@@ -471,7 +471,7 @@ const NotificationSection: React.FC<{
</Box>
<Box component="ul" sx={{ listStyle: "none", m: 0, p: 0 }}>
{conversations.map((conversation) => (
- <NotificationListItem
+ <ConversationListItem
key={conversationId(conversation)}
conversation={conversation}
onOpenThread={onOpenThread}
@@ -1046,7 +1046,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
today.getMonth(),
today.getDate() - 1,
).getTime();
- const nextSections: NotificationSectionItem[] = [
+ const nextSections: ConversationSectionItem[] = [
{ title: "New", conversations: [] },
{ title: "Today", conversations: [] },
{ title: "Yesterday", conversations: [] },
@@ -1225,9 +1225,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
<Box
component="button"
type="button"
- aria-label={
- isThreadOpen ? "Back to notifications" : "Back"
- }
+ aria-label={isThreadOpen ? "Back to messages" : "Back"}
onClick={isThreadOpen ? onCloseThread : onBack}
sx={{
alignItems: "center",
@@ -1329,7 +1327,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
whiteSpace: "nowrap",
}}
>
- Notifications
+ Messages
</Box>
)}
<Box aria-hidden />
@@ -1927,7 +1925,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
m: 0,
}}
>
- No notifications yet
+ No messages yet
</Box>
</Box>
) : (
@@ -1939,7 +1937,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({
}}
>
{groupedConversations.map((section) => (
- <NotificationSection
+ <ConversationSection
key={section.title}
conversations={section.conversations}
onOpenThread={onOpenThread}
diff --git a/web/apps/space/src/services/space.ts b/web/apps/space/src/services/space.ts
index 98ced7ee41..db7b1cc92a 100644
--- a/web/apps/space/src/services/space.ts
+++ b/web/apps/space/src/services/space.ts
@@ -265,6 +265,11 @@ export interface SpaceMessageConversationPage {
}
export interface SpaceUnreadStatus {
+ feedUnread: boolean;
+ messagesUnread: boolean;
+}
+
+interface SpaceUnreadStatusResponse {
feedUnread: boolean;
notificationsUnread: boolean;
}
@@ -890,7 +895,11 @@ export const loadCurrentFeedPage = async (
export const loadCurrentUnreadStatus = async (): Promise<SpaceUnreadStatus> => {
const ctx = await ensureCurrentSpaceContext();
try {
- return (await ctx.unread_status()) as SpaceUnreadStatus;
+ const status = (await ctx.unread_status()) as SpaceUnreadStatusResponse;
+ return {
+ feedUnread: status.feedUnread,
+ messagesUnread: status.notificationsUnread,
+ };
} finally {
releaseCurrentSpaceContext(ctx);
}
@@ -1127,7 +1136,7 @@ export const loadCurrentMessageThread = async (
}
};
-export const markCurrentNotificationsRead = async (friendSpaceId: string) => {
+export const markCurrentMessagesRead = async (friendSpaceId: string) => {
if (!friendSpaceId.trim()) return;
const ctx = await ensureCurrentSpaceContext();
try {
diff --git a/web/apps/space/src/utils/spaceRoutes.ts b/web/apps/space/src/utils/spaceRoutes.ts
index 9aeb76099f..ed96bf269c 100644
--- a/web/apps/space/src/utils/spaceRoutes.ts
+++ b/web/apps/space/src/utils/spaceRoutes.ts
@@ -10,7 +10,7 @@ export const spaceRoutes = {
home: "/app",
invite: "/invite",
login: "/login",
- notifications: "/app/notifications",
+ messages: "/app/messages",
onboarding: "/",
passkeysFinish: "/passkeys/finish",
passkeysVerify: "/passkeys/verify",