Skip to content

armgit / ente

Public Imported from GitHub
0

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

Improve iOS notification setup

Anand Baburajanb6c9e103f250
diff --git a/web/apps/space/src/components/SpacePWAInstallPrompt.tsx b/web/apps/space/src/components/SpacePWAInstallPrompt.tsx
index 47290d7523..8c3ab68c48 100644
--- a/web/apps/space/src/components/SpacePWAInstallPrompt.tsx
+++ b/web/apps/space/src/components/SpacePWAInstallPrompt.tsx
@@ -1,6 +1,7 @@
import {
AddSquareIcon,
ArrowDown01Icon,
+ Home01Icon,
MoreHorizontalIcon,
MoreVerticalIcon,
MultiplicationSignIcon,
@@ -332,12 +333,22 @@ interface SpacePWAInstallInstructionsProps {
open: boolean;
onClose: () => void;
onDismiss: () => void;
+ notificationEntryPoint?: "banner" | "settings";
+ purpose?: "install" | "notifications";
}
export const SpacePWAInstallInstructions: React.FC<
SpacePWAInstallInstructionsProps
-> = ({ mode, open, onClose, onDismiss }) => {
+> = ({
+ mode,
+ notificationEntryPoint = "settings",
+ open,
+ onClose,
+ onDismiss,
+ purpose = "install",
+}) => {
const titleID = React.useId();
+ const descriptionID = React.useId();
const isBottomSheet = useMediaQuery("(max-width: 599px)");
const shareStep: InstallStep = {
icon: <HugeiconsIcon icon={Upload01Icon} size={18} strokeWidth={2} />,
@@ -387,7 +398,7 @@ export const SpacePWAInstallInstructions: React.FC<
shareStep,
addHomeScreenStep,
];
- const steps: InstallStep[] =
+ const installSteps: InstallStep[] =
mode == "ios-chrome"
? iosChromeSteps
: mode == "ios-fallback"
@@ -426,6 +437,35 @@ export const SpacePWAInstallInstructions: React.FC<
text: 'Tap "Add to Home screen"',
},
];
+ const steps =
+ purpose == "notifications"
+ ? [
+ ...installSteps,
+ {
+ icon: (
+ <HugeiconsIcon
+ icon={Home01Icon}
+ size={18}
+ strokeWidth={2}
+ />
+ ),
+ text: "Open Space from your Home Screen",
+ },
+ {
+ icon: (
+ <HugeiconsIcon
+ icon={Notification02Icon}
+ size={18}
+ strokeWidth={2}
+ />
+ ),
+ text:
+ notificationEntryPoint == "banner"
+ ? 'Tap "Enable" to turn on notifications'
+ : "Turn on notifications in Settings",
+ },
+ ]
+ : installSteps;
return (
<Dialog
@@ -433,6 +473,9 @@ export const SpacePWAInstallInstructions: React.FC<
onClose={onClose}
maxWidth={false}
aria-labelledby={titleID}
+ aria-describedby={
+ purpose == "notifications" ? descriptionID : undefined
+ }
sx={{ "--space-dialog-backdrop": "rgba(0 0 0 / 0.56)" }}
slots={
isBottomSheet
@@ -490,8 +533,28 @@ export const SpacePWAInstallInstructions: React.FC<
textAlign: "center",
}}
>
- Add Space to your home screen
+ {purpose == "notifications"
+ ? "Turn on notifications"
+ : "Add Space to your home screen"}
</Box>
+ {purpose == "notifications" && (
+ <Box
+ component="p"
+ id={descriptionID}
+ sx={{
+ color: textSoft,
+ fontFamily: '"Inter Variable", Inter, sans-serif',
+ fontSize: 13,
+ lineHeight: "18px",
+ m: "8px 0 0",
+ px: "12px",
+ textAlign: "center",
+ }}
+ >
+ On iPhone, Space can send notifications only after
+ it&apos;s added to your Home Screen.
+ </Box>
+ )}
<Box sx={{ display: "grid", gap: "12px", mt: "22px" }}>
{steps.map((step, index) => (
<InstallInstructionStep
diff --git a/web/apps/space/src/components/SpacePublicProfileNotificationControl.tsx b/web/apps/space/src/components/SpacePublicProfileNotificationControl.tsx
index 5322f9ecef..bfd521fc46 100644
--- a/web/apps/space/src/components/SpacePublicProfileNotificationControl.tsx
+++ b/web/apps/space/src/components/SpacePublicProfileNotificationControl.tsx
@@ -1,8 +1,4 @@
-import {
- Notification02Icon,
- ScreenAddToHomeIcon,
- Tick02Icon,
-} from "@hugeicons/core-free-icons";
+import { Notification02Icon, Tick02Icon } from "@hugeicons/core-free-icons";
import { SpaceNotificationPermissionInstructions } from "components/SpaceNotificationPermissionInstructions";
import {
SpacePWAInstallInstructions,
@@ -112,7 +108,7 @@ export const SpacePublicProfileNotificationControl: React.FC<
canShowNotifications &&
(updating.current ||
(!busy && state != "subscribed" && state != "unavailable"));
- const hasInstallPrompt = requiresIOSInstall && installPrompt.shouldShow;
+ const hasInstallPrompt = requiresIOSInstall && installPrompt.canInstall;
const instructionsOpen =
installInstructionsOpen || permissionInstructionsOpen;
const showNotificationAction = hasNotificationAction && !instructionsOpen;
@@ -190,22 +186,21 @@ export const SpacePublicProfileNotificationControl: React.FC<
) : null}
{showInstallPrompt && (
<SpacePWAPromptBanner
- actionLabel="Add"
+ actionLabel="Enable"
hidden={isHiddenForScroll}
- icon={ScreenAddToHomeIcon}
- label="Add to home screen"
+ icon={Notification02Icon}
+ label="Get notified about new posts"
onAction={() => setInstallInstructionsOpen(true)}
placement="bottom"
/>
)}
<SpacePWAInstallInstructions
mode={installPrompt.mode}
+ notificationEntryPoint="banner"
open={installInstructionsOpen}
onClose={() => setInstallInstructionsOpen(false)}
- onDismiss={() => {
- setInstallInstructionsOpen(false);
- installPrompt.dismiss();
- }}
+ onDismiss={() => setInstallInstructionsOpen(false)}
+ purpose="notifications"
/>
<SpaceNotificationPermissionInstructions
mode={needsBravePushMessaging ? "brave-push" : "permission"}
diff --git a/web/apps/space/src/pages/_app.tsx b/web/apps/space/src/pages/_app.tsx
index c31cacb86e..f34f7758b0 100644
--- a/web/apps/space/src/pages/_app.tsx
+++ b/web/apps/space/src/pages/_app.tsx
@@ -36,7 +36,7 @@ const spaceTheme = createTheme(shareTheme, {
const App: React.FC<AppProps> = ({ Component, pageProps }) => {
useSetupLogs({ disableDiskLogs: true });
const router = useRouter();
- const publicProfileManifest = /^\/[^/?#]+#/.test(router.asPath);
+ const publicProfileManifest = router.pathname == "/profile-link";
React.useEffect(captureSpacePWAInstallPrompt, []);
React.useEffect(() => {
diff --git a/web/apps/space/src/screens/SettingsScreen.tsx b/web/apps/space/src/screens/SettingsScreen.tsx
index 96b6945e72..945991c325 100644
--- a/web/apps/space/src/screens/SettingsScreen.tsx
+++ b/web/apps/space/src/screens/SettingsScreen.tsx
@@ -330,7 +330,7 @@ const SettingsEyebrow: React.FC<{ children: React.ReactNode }> = ({
lineHeight: "16px",
m: 0,
px: "8px",
- "&:not(:first-child)": { mt: "16px" },
+ "&:not(:first-of-type)": { mt: "16px" },
}}
>
{children}
@@ -346,8 +346,8 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
}) => {
const installPrompt = useSpacePWAInstallPrompt();
const webPushPrompt = useSpaceWebPushPrompt();
- const [installInstructionsOpen, setInstallInstructionsOpen] =
- React.useState(false);
+ const [installInstructionsPurpose, setInstallInstructionsPurpose] =
+ React.useState<"install" | "notifications" | null>(null);
const [notificationInstructionsOpen, setNotificationInstructionsOpen] =
React.useState(false);
const [logoutSheetOpen, setLogoutSheetOpen] = React.useState(false);
@@ -378,13 +378,13 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
if (installPrompt.mode == "native") {
void installPrompt.install();
} else {
- setInstallInstructionsOpen(true);
+ setInstallInstructionsPurpose("install");
}
};
const toggleNotifications = () => {
if (requiresIOSInstall) {
- setInstallInstructionsOpen(true);
+ setInstallInstructionsPurpose("notifications");
} else if (webPushPrompt.permissionDenied) {
setNotificationInstructionsOpen(true);
} else {
@@ -510,10 +510,13 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
<SettingsRow
icon={Notification02Icon}
label="Notifications"
+ onClick={
+ requiresIOSInstall ? toggleNotifications : undefined
+ }
trailingOnClick={
webPushPrompt.isResolved &&
!webPushPrompt.isEnabling &&
- (requiresIOSInstall || webPushPrompt.isAvailable)
+ webPushPrompt.isAvailable
? toggleNotifications
: undefined
}
@@ -588,9 +591,10 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({
/>
<SpacePWAInstallInstructions
mode={installPrompt.mode}
- open={installInstructionsOpen}
- onClose={() => setInstallInstructionsOpen(false)}
- onDismiss={() => setInstallInstructionsOpen(false)}
+ open={installInstructionsPurpose != null}
+ onClose={() => setInstallInstructionsPurpose(null)}
+ onDismiss={() => setInstallInstructionsPurpose(null)}
+ purpose={installInstructionsPurpose ?? "install"}
/>
<SpaceNotificationPermissionInstructions
mode={