Skip to content

armgit / ente

Public Imported from GitHub
0

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

Skip invite step for add friend onboarding

Anand Baburajan28c683be0e9e
diff --git a/web/apps/social/src/pages/index.tsx b/web/apps/social/src/pages/index.tsx
index f219ed3106..0335e08e63 100644
--- a/web/apps/social/src/pages/index.tsx
+++ b/web/apps/social/src/pages/index.tsx
@@ -46,6 +46,10 @@ type Screen =
type ProfileBackScreen = "login" | "verify-email";
type FriendProfileBackScreen = "friends" | "home";
+type OnboardingEntrySource = "direct" | "add-friend-link";
+
+const onboardingSourceSearchParam = "onboardingSource";
+const addFriendLinkOnboardingSource: OnboardingEntrySource = "add-friend-link";
const samplePublicProfileData = {
avatarUrl: "/images/sample-avatar.jpg",
@@ -76,6 +80,26 @@ const parsePublicProfileLink = (): PublicProfileLink | null => {
}
};
+const parseOnboardingEntrySource = (): OnboardingEntrySource => {
+ const params = new URLSearchParams(window.location.search);
+ return params.get(onboardingSourceSearchParam) ==
+ addFriendLinkOnboardingSource
+ ? "add-friend-link"
+ : "direct";
+};
+
+const removeOnboardingEntrySourceFromURL = () => {
+ const url = new URL(window.location.href);
+ if (!url.searchParams.has(onboardingSourceSearchParam)) return;
+
+ url.searchParams.delete(onboardingSourceSearchParam);
+ window.history.replaceState(
+ window.history.state,
+ "",
+ `${url.pathname}${url.search}${url.hash}`,
+ );
+};
+
const publicProfileFromLink = (): SetupProfile => ({
avatarUrl: samplePublicProfileData.avatarUrl,
fullName: samplePublicProfileData.fullName,
@@ -87,6 +111,8 @@ const Page: React.FC = () => {
const [screen, setScreen] = useState<Screen>("onboarding");
const [email, setEmail] = useState("[email protected]");
const [friends, setFriends] = useState(sampleFriends);
+ const [onboardingEntrySource, setOnboardingEntrySource] =
+ useState<OnboardingEntrySource>("direct");
const [profile, setProfile] = useState<SetupProfile | null>(null);
const [profileBackScreen, setProfileBackScreen] =
useState<ProfileBackScreen>("verify-email");
@@ -112,6 +138,10 @@ const Page: React.FC = () => {
useEffect(() => {
const publicProfileLink = parsePublicProfileLink();
+ if (!publicProfileLink) {
+ setOnboardingEntrySource(parseOnboardingEntrySource());
+ removeOnboardingEntrySourceFromURL();
+ }
setRouteMode(
publicProfileLink
? { kind: "public-profile", ...publicProfileLink }
@@ -123,6 +153,8 @@ const Page: React.FC = () => {
? (friends.find((friend) => friend.id == selectedFriendID) ??
sampleFriends.find((friend) => friend.id == selectedFriendID))
: undefined;
+ const isAddFriendLinkOnboarding =
+ onboardingEntrySource == "add-friend-link";
const themeColor =
routeMode.kind != "app"
@@ -166,7 +198,14 @@ const Page: React.FC = () => {
{routeMode.kind == "checking" ? (
<Box sx={{ bgcolor: profileBackground, minHeight: "100svh" }} />
) : routeMode.kind == "public-profile" ? (
- <PublicProfileScreen profile={publicProfileFromLink()} />
+ <PublicProfileScreen
+ profile={publicProfileFromLink()}
+ onAddFriend={() => {
+ window.location.assign(
+ `/?${onboardingSourceSearchParam}=${addFriendLinkOnboardingSource}`,
+ );
+ }}
+ />
) : (
<>
{screen == "onboarding" && (
@@ -202,10 +241,17 @@ const Page: React.FC = () => {
)}
{screen == "setup-profile" && (
<SetupProfileScreen
+ ctaLabel={
+ isAddFriendLinkOnboarding ? "Done" : "Next"
+ }
onBack={() => setScreen(profileBackScreen)}
onContinue={(nextProfile) => {
setProfile(nextProfile);
- setScreen("share-profile-link");
+ setScreen(
+ isAddFriendLinkOnboarding
+ ? "home"
+ : "share-profile-link",
+ );
}}
/>
)}
@@ -267,6 +313,7 @@ const Page: React.FC = () => {
onBack={() => setScreen("profile")}
onLogout={() => {
setProfile(null);
+ setOnboardingEntrySource("direct");
setSelectedFriendID(null);
setFriends(sampleFriends);
setScreen("onboarding");
diff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsx
index 6e324a5fb4..e7495bf5cf 100644
--- a/web/apps/social/src/screens/ProfileScreen.tsx
+++ b/web/apps/social/src/screens/ProfileScreen.tsx
@@ -159,6 +159,7 @@ const buildPostMasonryRows = (items: SamplePostItem[]): PostMasonryRow[] => {
interface ProfileScreenProps {
friendsCount?: number;
headerVariant?: "friend" | "owner" | "public";
+ onAddFriend?: () => void;
onBack?: () => void;
onOpenFriends?: () => void;
onOpenSettings?: () => void;
@@ -168,6 +169,7 @@ interface ProfileScreenProps {
export const ProfileScreen: React.FC<ProfileScreenProps> = ({
friendsCount = 7,
headerVariant = "owner",
+ onAddFriend,
onBack,
onOpenFriends,
onOpenSettings,
@@ -340,16 +342,14 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({
<Box
component="button"
type="button"
- onClick={() => {
- window.location.assign("/");
- }}
+ onClick={onAddFriend}
sx={{
alignItems: "center",
backgroundColor: "#FFFFFF",
border: 0,
borderRadius: "999px",
color: green,
- cursor: "pointer",
+ cursor: onAddFriend ? "pointer" : "default",
display: "inline-flex",
fontFamily:
'"Inter Variable", Inter, sans-serif',
diff --git a/web/apps/social/src/screens/PublicProfileScreen.tsx b/web/apps/social/src/screens/PublicProfileScreen.tsx
index cdad670c13..e7ccf3b136 100644
--- a/web/apps/social/src/screens/PublicProfileScreen.tsx
+++ b/web/apps/social/src/screens/PublicProfileScreen.tsx
@@ -3,9 +3,17 @@ import { ProfileScreen } from "screens/ProfileScreen";
import type { SetupProfile } from "screens/SetupProfileScreen";
interface PublicProfileScreenProps {
+ onAddFriend?: () => void;
profile: SetupProfile;
}
export const PublicProfileScreen: React.FC<PublicProfileScreenProps> = ({
+ onAddFriend,
profile,
-}) => <ProfileScreen headerVariant="public" profile={profile} />;
+}) => (
+ <ProfileScreen
+ headerVariant="public"
+ onAddFriend={onAddFriend}
+ profile={profile}
+ />
+);
diff --git a/web/apps/social/src/screens/SetupProfileScreen.tsx b/web/apps/social/src/screens/SetupProfileScreen.tsx
index 35c4b53456..275ad2f61c 100644
--- a/web/apps/social/src/screens/SetupProfileScreen.tsx
+++ b/web/apps/social/src/screens/SetupProfileScreen.tsx
@@ -22,6 +22,7 @@ export interface SetupProfile {
}
interface SetupProfileScreenProps {
+ ctaLabel?: string;
onBack: () => void;
onContinue?: (profile: SetupProfile) => void;
}
@@ -160,6 +161,7 @@ const TextInput: React.FC<TextInputProps> = ({
);
export const SetupProfileScreen: React.FC<SetupProfileScreenProps> = ({
+ ctaLabel = "Next",
onBack,
onContinue,
}) => {
@@ -477,7 +479,7 @@ export const SetupProfileScreen: React.FC<SetupProfileScreenProps> = ({
: undefined,
}}
>
- Next
+ {ctaLabel}
</Box>
</Box>
</Box>