Skip to content

armgit / ente

Public Imported from GitHub
0

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

Gate Space notification UI for pilot users

Anand Baburajana7870a5d450c
diff --git a/web/apps/space/src/hooks/useSpaceWebPushPrompt.ts b/web/apps/space/src/hooks/useSpaceWebPushPrompt.ts
index 1a7c9b99e5..34d36e26ae 100644
--- a/web/apps/space/src/hooks/useSpaceWebPushPrompt.ts
+++ b/web/apps/space/src/hooks/useSpaceWebPushPrompt.ts
@@ -1,3 +1,4 @@
+import { savedPartialLocalUser } from "ente-accounts-rs/services/accounts-db";
import { isSpaceIOS, isSpaceStandalone } from "hooks/useSpacePWAInstallPrompt";
import React from "react";
import {
@@ -8,6 +9,7 @@ import {
unsubscribeFromSpaceWebPush,
type SpaceWebPushState,
} from "services/spaceWebPush";
+import { isSpaceWebPushPilotAccount } from "services/spaceWebPushPilot";
type PromptStatus = "enabling" | "error" | "hidden" | "loading" | "ready";
@@ -49,6 +51,7 @@ const isDismissed = () => {
export const useSpaceWebPushPrompt = () => {
const updating = React.useRef(false);
const [isAvailable, setIsAvailable] = React.useState(false);
+ const [isPilotEligible, setIsPilotEligible] = React.useState(false);
const [isSubscribed, setIsSubscribed] = React.useState<boolean | null>(
null,
);
@@ -59,8 +62,14 @@ export const useSpaceWebPushPrompt = () => {
const [status, setStatus] = React.useState<PromptStatus>("loading");
React.useEffect(() => {
+ const pilotEligible = isSpaceWebPushPilotAccount(
+ savedPartialLocalUser()?.email,
+ );
+ setIsPilotEligible(pilotEligible);
const available =
- isSpaceWebPushSupported() && (!isSpaceIOS() || isSpaceStandalone());
+ pilotEligible &&
+ isSpaceWebPushSupported() &&
+ (!isSpaceIOS() || isSpaceStandalone());
setIsAvailable(available);
if (!available) {
setStatus("hidden");
@@ -171,6 +180,7 @@ export const useSpaceWebPushPrompt = () => {
enable,
isAvailable,
isEnabling: status == "enabling",
+ isPilotEligible,
isResolved: status != "loading",
isSubscribed,
needsBravePushMessaging,
diff --git a/web/apps/space/src/pages/index.tsx b/web/apps/space/src/pages/index.tsx
index 519322fd91..c0d1e8bcc5 100644
--- a/web/apps/space/src/pages/index.tsx
+++ b/web/apps/space/src/pages/index.tsx
@@ -37,6 +37,7 @@ import {
type SpaceInviteIntent,
type SpaceInviteRoute,
} from "services/spaceInvite";
+import { isSpaceWebPushPilotPublicPage } from "services/spaceWebPushPilot";
import {
useSpaceAppState,
type OnboardingEntrySource,
@@ -645,9 +646,13 @@ export const Page: React.FC<PageProps> = ({ invitePreview }) => {
postsCount={publicLink.postsCount}
profile={publicLink.profile}
publicNotificationControl={
- <SpacePublicProfileNotificationControl
- session={publicLink}
- />
+ isSpaceWebPushPilotPublicPage(
+ publicIdentity.username,
+ ) ? (
+ <SpacePublicProfileNotificationControl
+ session={publicLink}
+ />
+ ) : undefined
}
showAddingFriendSpinner={
isAddingFriend && Boolean(profile)
diff --git a/web/apps/space/src/screens/SettingsScreen.tsx b/web/apps/space/src/screens/SettingsScreen.tsx
index 945991c325..3ac5463278 100644
--- a/web/apps/space/src/screens/SettingsScreen.tsx
+++ b/web/apps/space/src/screens/SettingsScreen.tsx
@@ -507,28 +507,32 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
onClick={onChangeCoverImage}
/>
<SettingsEyebrow>PREFERENCES</SettingsEyebrow>
- <SettingsRow
- icon={Notification02Icon}
- label="Notifications"
- onClick={
- requiresIOSInstall ? toggleNotifications : undefined
- }
- trailingOnClick={
- webPushPrompt.isResolved &&
- !webPushPrompt.isEnabling &&
- webPushPrompt.isAvailable
- ? toggleNotifications
- : undefined
- }
- toggleState={
- requiresIOSInstall
- ? undefined
- : webPushPrompt.isResolved &&
- webPushPrompt.isAvailable
- ? Boolean(webPushPrompt.isSubscribed)
- : null
- }
- />
+ {webPushPrompt.isPilotEligible && (
+ <SettingsRow
+ icon={Notification02Icon}
+ label="Notifications"
+ onClick={
+ requiresIOSInstall
+ ? toggleNotifications
+ : undefined
+ }
+ trailingOnClick={
+ webPushPrompt.isResolved &&
+ !webPushPrompt.isEnabling &&
+ webPushPrompt.isAvailable
+ ? toggleNotifications
+ : undefined
+ }
+ toggleState={
+ requiresIOSInstall
+ ? undefined
+ : webPushPrompt.isResolved &&
+ webPushPrompt.isAvailable
+ ? Boolean(webPushPrompt.isSubscribed)
+ : null
+ }
+ />
+ )}
{installPrompt.canInstall && (
<SettingsRow
icon={ScreenAddToHomeIcon}
diff --git a/web/apps/space/src/services/spaceWebPushPilot.ts b/web/apps/space/src/services/spaceWebPushPilot.ts
new file mode 100644
index 0000000000..ca2841c656
--- /dev/null
+++ b/web/apps/space/src/services/spaceWebPushPilot.ts
@@ -0,0 +1,14 @@
+const pilotAccountEmails = new Set([
+]);
+const pilotPublicUsernames = new Set(["anand", "anandbaburajan"]);
+
+const normalize = (value: string | undefined) =>
+ value?.trim().toLowerCase() ?? "";
+
+export const isSpaceWebPushPilotAccount = (email: string | undefined) =>
+ pilotAccountEmails.has(normalize(email));
+
+export const isSpaceWebPushPilotPublicPage = (username: string | undefined) =>
+ pilotPublicUsernames.has(normalize(username));