π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update social app routing and branding
Anand Baburajanc0c8e48199d6
diff --git a/server/configurations/local.yaml b/server/configurations/local.yamlindex 5f935e83c2..e33b474ef3 100644--- a/server/configurations/local.yaml+++ b/server/configurations/local.yaml@@ -108,7 +108,7 @@ apps:accounts:# Default is https://family.ente.iofamily:- # Default is https://ente.gg+ # Default is https://ente.space# Set this to the URL where your social web app is running.social:# Default is https://memories.ente.iodiff --git a/server/wall/controller/notifications.go b/server/wall/controller/notifications.goindex 552ec0b402..5f387fca35 100644--- a/server/wall/controller/notifications.go+++ b/server/wall/controller/notifications.go@@ -86,7 +86,7 @@ func uniqueUserIDs(userIDs []int64) []int64 {func socialAppURL() string {origin := strings.TrimRight(strings.TrimSpace(viper.GetString("apps.social")), "/")if origin == "" {- origin = "https://ente.gg"+ origin = "https://ente.space"}return origin + "/app"}diff --git a/web/apps/social/public/_redirects b/web/apps/social/public/_redirectsindex 4aa7faf062..c74eeee3b5 100644--- a/web/apps/social/public/_redirects+++ b/web/apps/social/public/_redirects@@ -1 +1,2 @@+/app/friends/* /app/friends/[wallId].html 200/* /index.html 200diff --git a/web/apps/social/public/manifest.webmanifest b/web/apps/social/public/manifest.webmanifestindex 5bc3ee1fa4..20e06bc2ef 100644--- a/web/apps/social/public/manifest.webmanifest+++ b/web/apps/social/public/manifest.webmanifest@@ -1,5 +1,5 @@{- "name": "Ente Social",+ "name": "Ente Space","short_name": "Ente","description": "Share moments with friends on Ente.","start_url": "/app",diff --git a/web/apps/social/src/pages/_app.tsx b/web/apps/social/src/pages/_app.tsxindex 0c7ff48a98..8149bf8b58 100644--- a/web/apps/social/src/pages/_app.tsx+++ b/web/apps/social/src/pages/_app.tsx@@ -19,11 +19,11 @@ const App: React.FC<AppProps> = ({ Component, pageProps }) => {defaultMode="light"storageManager={null}>- <CustomHead title="Ente Social">- <meta name="application-name" content="Ente Social" />+ <CustomHead title="Ente Space">+ <meta name="application-name" content="Ente Space" /><meta name="mobile-web-app-capable" content="yes" /><meta name="apple-mobile-web-app-capable" content="yes" />- <meta name="apple-mobile-web-app-title" content="Ente Social" />+ <meta name="apple-mobile-web-app-title" content="Ente Space" /><metaname="apple-mobile-web-app-status-bar-style"content="default"diff --git a/web/apps/social/src/pages/app/friend.tsx b/web/apps/social/src/pages/app/friend.tsxindex bcf81278b5..c91ac2630d 100644--- a/web/apps/social/src/pages/app/friend.tsx+++ b/web/apps/social/src/pages/app/friend.tsx@@ -1,123 +1,21 @@-import { SocialPageMeta } from "components/SocialPageMeta";import { SocialRouteFallback } from "components/SocialRouteFallback";import { useRouter } from "next/router";-import React, { useEffect, useMemo, useState } from "react";+import React, { useEffect } from "react";import { friendsBackground } from "screens/FriendsScreen";-import { ProfileScreen } from "screens/ProfileScreen";-import {- loadCurrentPostLikers,- loadCurrentWallFriends,- loadCurrentWallPostsPage,- setCurrentPostLiked,- type SocialWallPost,-} from "services/socialWall";-import { useSocialAppState } from "state/socialAppState";-import {- friendIDFromQuery,- friendProfileSourceFromQuery,- socialRoutes,-} from "utils/socialRoutes";-import { profilePostGroupsFromPosts } from "utils/socialWallDisplay";--const backRouteForSource = (- source: ReturnType<typeof friendProfileSourceFromQuery>,-) =>- source == "home"- ? socialRoutes.home- : source == "profile"- ? socialRoutes.profile- : socialRoutes.friends;+import { friendWallIdFromQuery, socialRoutes } from "utils/socialRoutes";const Page: React.FC = () => {const router = useRouter();- const { friends, profile, profileLoadStatus, setFriends } =- useSocialAppState();- const friendID = friendIDFromQuery(router.query.friendID);- const backSource = friendProfileSourceFromQuery(router.query.from);- const selectedFriend = friends.find((friend) => friend.id == friendID);- const [friendsLoadAttempted, setFriendsLoadAttempted] = useState(false);- const [posts, setPosts] = useState<SocialWallPost[]>([]);- const postGroups = useMemo(- () => profilePostGroupsFromPosts(posts),- [posts],- );useEffect(() => {if (!router.isReady) return;- if (profileLoadStatus == "ready" && !profile) {- void router.replace(socialRoutes.onboarding);- return;- }- if (- profileLoadStatus == "ready" &&- friendsLoadAttempted &&- !selectedFriend- ) {- void router.replace(socialRoutes.friends);- }- }, [- friendsLoadAttempted,- profile,- profileLoadStatus,- router,- selectedFriend,- ]);-- useEffect(() => {- if (!profile?.wallId) return;-- void loadCurrentWallFriends(profile.wallId)- .then(setFriends)- .catch((error: unknown) =>- console.error("Failed to load social friends", error),- )- .finally(() => setFriendsLoadAttempted(true));- }, [profile?.wallId, setFriends]);-- useEffect(() => {- if (!selectedFriend?.wallId) return;-- void loadCurrentWallPostsPage(selectedFriend.wallId)- .then((page) => setPosts(page.items))- .catch((error: unknown) =>- console.error("Failed to load friend posts", error),- );- }, [selectedFriend?.wallId]);-- if (- !router.isReady ||- profileLoadStatus == "loading" ||- !profile ||- !selectedFriend- ) {- return <SocialRouteFallback background={friendsBackground} />;- }+ const friendID = friendWallIdFromQuery(router.query.friendID);+ void router.replace(+ friendID ? socialRoutes.friend(friendID) : socialRoutes.friends,+ );+ }, [router]);- return (- <>- <SocialPageMeta themeColor={friendsBackground} />- <ProfileScreen- friendsCount={selectedFriend.friendsCount}- headerVariant="friend"- postGroups={postGroups}- profile={{- avatarUrl: selectedFriend.avatarUrl ?? null,- fullName: selectedFriend.fullName,- username: selectedFriend.username,- wallId: selectedFriend.wallId,- wallSlug: selectedFriend.wallSlug,- }}- onBack={() => void router.push(backRouteForSource(backSource))}- onOpenFriend={(nextFriendID) =>- void router.push(- socialRoutes.friend(nextFriendID, backSource),- )- }- onLoadPostLikers={loadCurrentPostLikers}- onSetPostLiked={setCurrentPostLiked}- />- </>- );+ return <SocialRouteFallback background={friendsBackground} />;};export default Page;diff --git a/web/apps/social/src/pages/app/friends/[wallId].tsx b/web/apps/social/src/pages/app/friends/[wallId].tsxnew file mode 100644index 0000000000..5b07761773--- /dev/null+++ b/web/apps/social/src/pages/app/friends/[wallId].tsx@@ -0,0 +1,130 @@+import { SocialPageMeta } from "components/SocialPageMeta";+import { SocialRouteFallback } from "components/SocialRouteFallback";+import { useRouter } from "next/router";+import React, { useEffect, useMemo, useState } from "react";+import { friendsBackground } from "screens/FriendsScreen";+import { ProfileScreen } from "screens/ProfileScreen";+import {+ loadCurrentPostLikers,+ loadCurrentWallFriends,+ loadCurrentWallPostsPage,+ setCurrentPostLiked,+ type SocialWallPost,+} from "services/socialWall";+import { useSocialAppState } from "state/socialAppState";+import { friendWallIdFromQuery, socialRoutes } from "utils/socialRoutes";+import { profilePostGroupsFromPosts } from "utils/socialWallDisplay";++const friendWallIdFromPath = () => {+ if (typeof window == "undefined") return "";+ const match = /^\/app\/friends\/([^/?#]+)/.exec(window.location.pathname);+ if (!match?.[1]) return "";++ try {+ return decodeURIComponent(match[1]);+ } catch {+ return "";+ }+};++const Page: React.FC = () => {+ const router = useRouter();+ const { friends, profile, profileLoadStatus, setFriends } =+ useSocialAppState();+ const friendWallId =+ friendWallIdFromQuery(router.query.wallId) || friendWallIdFromPath();+ const selectedFriend = friends.find(+ (friend) => friend.wallId == friendWallId || friend.id == friendWallId,+ );+ const [friendsLoadAttempted, setFriendsLoadAttempted] = useState(false);+ const [posts, setPosts] = useState<SocialWallPost[]>([]);+ const postGroups = useMemo(+ () => profilePostGroupsFromPosts(posts),+ [posts],+ );++ useEffect(() => {+ if (!router.isReady) return;+ if (profileLoadStatus == "ready" && !profile) {+ void router.replace(socialRoutes.onboarding);+ return;+ }+ if (+ profileLoadStatus == "ready" &&+ friendsLoadAttempted &&+ !selectedFriend+ ) {+ void router.replace(socialRoutes.friends);+ }+ }, [+ friendsLoadAttempted,+ profile,+ profileLoadStatus,+ router,+ selectedFriend,+ ]);++ useEffect(() => {+ if (!profile?.wallId) return;++ void loadCurrentWallFriends(profile.wallId)+ .then(setFriends)+ .catch((error: unknown) =>+ console.error("Failed to load social friends", error),+ )+ .finally(() => setFriendsLoadAttempted(true));+ }, [profile?.wallId, setFriends]);++ useEffect(() => {+ if (!selectedFriend?.wallId) return;++ void loadCurrentWallPostsPage(selectedFriend.wallId)+ .then((page) => setPosts(page.items))+ .catch((error: unknown) =>+ console.error("Failed to load friend posts", error),+ );+ }, [selectedFriend?.wallId]);++ const goBack = () => {+ if (typeof window != "undefined" && window.history.length > 1) {+ router.back();+ return;+ }+ void router.push(socialRoutes.friends);+ };++ if (+ !router.isReady ||+ profileLoadStatus == "loading" ||+ !profile ||+ !selectedFriend+ ) {+ return <SocialRouteFallback background={friendsBackground} />;+ }++ return (+ <>+ <SocialPageMeta themeColor={friendsBackground} />+ <ProfileScreen+ friendsCount={selectedFriend.friendsCount}+ headerVariant="friend"+ postGroups={postGroups}+ profile={{+ avatarUrl: selectedFriend.avatarUrl ?? null,+ fullName: selectedFriend.fullName,+ username: selectedFriend.username,+ wallId: selectedFriend.wallId,+ wallSlug: selectedFriend.wallSlug,+ }}+ onBack={goBack}+ onOpenFriend={(nextFriendID) =>+ void router.push(socialRoutes.friend(nextFriendID))+ }+ onLoadPostLikers={loadCurrentPostLikers}+ onSetPostLiked={setCurrentPostLiked}+ />+ </>+ );+};++export default Page;diff --git a/web/apps/social/src/pages/app/friends.tsx b/web/apps/social/src/pages/app/friends/index.tsxsimilarity index 94%rename from web/apps/social/src/pages/app/friends.tsxrename to web/apps/social/src/pages/app/friends/index.tsxindex 6f6fd7d6ff..5f6bb39cac 100644--- a/web/apps/social/src/pages/app/friends.tsx+++ b/web/apps/social/src/pages/app/friends/index.tsx@@ -42,13 +42,14 @@ const Page: React.FC = () => {friends={friends}onBack={() => void router.push(socialRoutes.profile)}onOpenFriend={(friendID) =>- void router.push(socialRoutes.friend(friendID, "friends"))+ void router.push(socialRoutes.friend(friendID))}onUnfriend={(friendID) => {const friend = friends.find((candidate) => candidate.id == friendID,);- if (friend?.wallId) void removeCurrentWallFriend(friend.wallId);+ if (friend?.wallId)+ void removeCurrentWallFriend(friend.wallId);setFriends((currentFriends) =>currentFriends.filter((candidate) => candidate.id != friendID,diff --git a/web/apps/social/src/pages/app/index.tsx b/web/apps/social/src/pages/app/index.tsxindex c1d17851d5..d9b19d4450 100644--- a/web/apps/social/src/pages/app/index.tsx+++ b/web/apps/social/src/pages/app/index.tsx@@ -126,7 +126,7 @@ const Page: React.FC = () => {return socialPostToViewerPhoto(post);}}onOpenFriend={(friendID) =>- void router.push(socialRoutes.friend(friendID, "home"))+ void router.push(socialRoutes.friend(friendID))}onOpenNotifications={() =>void router.push(socialRoutes.notifications)diff --git a/web/apps/social/src/pages/app/notifications.tsx b/web/apps/social/src/pages/app/notifications.tsxindex 15f388b837..c3b47f7ac4 100644--- a/web/apps/social/src/pages/app/notifications.tsx+++ b/web/apps/social/src/pages/app/notifications.tsx@@ -46,7 +46,8 @@ const Page: React.FC = () => {const openConversation = React.useCallback((conversation: SocialWallMessageConversation) => {setSelectedFriend(conversation.friend);- const friendWallId = conversation.friend.wallId ?? conversation.friend.id;+ const friendWallId =+ conversation.friend.wallId ?? conversation.friend.id;setConversations((currentConversations) =>currentConversations.map((currentConversation) =>(currentConversation.friend.wallId ??@@ -117,6 +118,11 @@ const Page: React.FC = () => {messages={messages}onBack={() => void router.push(socialRoutes.home)}onCloseThread={() => setSelectedFriend(undefined)}+ onOpenSelectedFriendProfile={(friend) =>+ void router.push(+ socialRoutes.friend(friend.wallId ?? friend.id),+ )+ }onOpenThread={openConversation}onSendMessage={async (wallId, text) => {const message = await sendCurrentMessage(wallId, text);diff --git a/web/apps/social/src/pages/app/profile.tsx b/web/apps/social/src/pages/app/profile.tsxindex e19c79760e..52a28f4ea3 100644--- a/web/apps/social/src/pages/app/profile.tsx+++ b/web/apps/social/src/pages/app/profile.tsx@@ -102,7 +102,7 @@ const Page: React.FC = () => {);}}onOpenFriend={(friendID) =>- void router.push(socialRoutes.friend(friendID, "profile"))+ void router.push(socialRoutes.friend(friendID))}onOpenFriends={() => void router.push(socialRoutes.friends)}onOpenSettings={() => void router.push(socialRoutes.settings)}diff --git a/web/apps/social/src/screens/MessagesScreen.tsx b/web/apps/social/src/screens/MessagesScreen.tsxindex 236ee1a4f7..cb5e136b16 100644--- a/web/apps/social/src/screens/MessagesScreen.tsx+++ b/web/apps/social/src/screens/MessagesScreen.tsx@@ -57,6 +57,9 @@ interface MessagesScreenProps {onBack?: () => void;onCloseThread: () => void;onDeleteMessage: (messageId: string) => Promise<void>;+ onOpenSelectedFriendProfile: (+ friend: SocialWallMessageConversation["friend"],+ ) => void;onOpenThread: (conversation: SocialWallMessageConversation) => void;onReplyToMessage: (wallId: string,@@ -812,6 +815,7 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({onBack,onCloseThread,onDeleteMessage,+ onOpenSelectedFriendProfile,onOpenThread,onReplyToMessage,onSendMessage,@@ -1004,26 +1008,79 @@ export const MessagesScreen: React.FC<MessagesScreenProps> = ({strokeWidth={1.8}/></Box>- <Box- component="h1"- sx={{- color: "inherit",- fontFamily: '"Inter Variable", Inter, sans-serif',- fontSize: 18,- fontWeight: 700,- justifySelf: "center",- lineHeight: "24px",- m: 0,- minWidth: 0,- overflow: "hidden",- textOverflow: "ellipsis",- whiteSpace: "nowrap",- }}- >- {isThreadOpen- ? firstNameFrom(selectedName)- : "Notifications"}- </Box>+ {isThreadOpen && selectedFriend ? (+ <Box+ component="h1"+ sx={{+ justifySelf: "center",+ m: 0,+ minWidth: 0,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ }}+ >+ <Box+ component="button"+ type="button"+ aria-label={+ selectedName+ ? `Open ${selectedName}'s profile`+ : "Open friend profile"+ }+ onClick={() =>+ onOpenSelectedFriendProfile(selectedFriend)+ }+ sx={{+ appearance: "none",+ bgcolor: "transparent",+ border: 0,+ color: "inherit",+ cursor: "pointer",+ display: "block",+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 18,+ fontWeight: 700,+ lineHeight: "24px",+ m: 0,+ maxWidth: "100%",+ minWidth: 0,+ overflow: "hidden",+ p: 0,+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ "&:focus-visible": {+ borderRadius: "4px",+ outline: `2px solid ${green}`,+ outlineOffset: 3,+ },+ }}+ >+ {firstNameFrom(selectedName)}+ </Box>+ </Box>+ ) : (+ <Box+ component="h1"+ sx={{+ color: "inherit",+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 18,+ fontWeight: 700,+ justifySelf: "center",+ lineHeight: "24px",+ m: 0,+ minWidth: 0,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ }}+ >+ Notifications+ </Box>+ )}<Box aria-hidden /></Box>diff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsxindex a0146d5402..15d834367a 100644--- a/web/apps/social/src/screens/ProfileScreen.tsx+++ b/web/apps/social/src/screens/ProfileScreen.tsx@@ -1,8 +1,8 @@import {AddSquareIcon,ArrowLeft02Icon,+ Menu01Icon,MoreHorizontalIcon,- Settings01Icon,Tick02Icon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";@@ -559,9 +559,9 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({}}><HugeiconsIcon- icon={Settings01Icon}- size={19}- strokeWidth={1.8}+ icon={Menu01Icon}+ size={20}+ strokeWidth={2.4}/></Box>) : (diff --git a/web/apps/social/src/utils/socialRoutes.ts b/web/apps/social/src/utils/socialRoutes.tsindex a10f513358..edf1249c66 100644--- a/web/apps/social/src/utils/socialRoutes.ts+++ b/web/apps/social/src/utils/socialRoutes.ts@@ -1,5 +1,4 @@export type SetupProfileSource = "login" | "verify";-export type FriendProfileSource = "friends" | "home" | "profile";export type VerifyFlow = "login" | "signup";export const onboardingSourceSearchParam = "onboardingSource";@@ -9,8 +8,7 @@ const valueFromQuery = (value: string | string[] | undefined) =>Array.isArray(value) ? value[0] : value;export const socialRoutes = {- friend: (friendID: string, from: FriendProfileSource) =>- `/app/friend?friendID=${encodeURIComponent(friendID)}&from=${from}`,+ friend: (wallId: string) => `/app/friends/${encodeURIComponent(wallId)}`,friends: "/app/friends",home: "/app",invite: "/invite",@@ -38,14 +36,5 @@ export const setupProfileSourceFromQuery = (): SetupProfileSource =>valueFromQuery(value) == "login" ? "login" : "verify";-export const friendProfileSourceFromQuery = (- value: string | string[] | undefined,-): FriendProfileSource => {- const from = valueFromQuery(value);- return from == "home" || from == "profile" || from == "friends"- ? from- : "friends";-};--export const friendIDFromQuery = (value: string | string[] | undefined) =>+export const friendWallIdFromQuery = (value: string | string[] | undefined) =>valueFromQuery(value) ?? "";