fix(mobile): explain iOS-only settings on Android (#4981)
This commit is contained in:
1 parent
270489b887
commit
4db50757c0
4 files changed
+40
-1
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { resolveAgentAwarenessPlatformPresentation } from "./SettingsRouteScreen.logic";
|
||||
|
||||
describe("resolveAgentAwarenessPlatformPresentation", () => {
|
||||
it("explains that agent awareness settings are unavailable on Android", () => {
|
||||
expect(resolveAgentAwarenessPlatformPresentation("android")).toEqual({
|
||||
supported: false,
|
||||
subtitle: "iOS only",
|
||||
});
|
||||
});
|
||||
|
||||
it("leaves supported iOS settings unchanged", () => {
|
||||
expect(resolveAgentAwarenessPlatformPresentation("ios")).toEqual({
|
||||
supported: true,
|
||||
subtitle: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
export function resolveAgentAwarenessPlatformPresentation(platform: string): {
|
||||
readonly supported: boolean;
|
||||
readonly subtitle: string | undefined;
|
||||
} {
|
||||
return platform === "ios"
|
||||
? { supported: true, subtitle: undefined }
|
||||
: { supported: false, subtitle: "iOS only" };
|
||||
}
|
||||
@@ -46,6 +46,7 @@ import { useSavedRemoteConnections } from "../../state/use-remote-environment-re
|
||||
import { SettingsRow } from "./components/SettingsRow";
|
||||
import { SettingsSection } from "./components/SettingsSection";
|
||||
import { SettingsSwitchRow } from "./components/SettingsSwitchRow";
|
||||
import { resolveAgentAwarenessPlatformPresentation } from "./SettingsRouteScreen.logic";
|
||||
|
||||
type NotificationStatus = "checking" | "enabled" | "disabled" | "unsupported";
|
||||
type LiveActivityStatus = "checking" | "enabled" | "disabled" | "signed-out" | "linking";
|
||||
@@ -144,6 +145,7 @@ function ConfiguredSettingsRouteScreen() {
|
||||
const preferencesResult = useAtomValue(mobilePreferencesAtom);
|
||||
const savePreferences = useAtomSet(updateMobilePreferencesAtom);
|
||||
const agentAwarenessPushAvailable = supportsAgentAwarenessPush();
|
||||
const agentAwarenessPlatform = resolveAgentAwarenessPlatformPresentation(Platform.OS);
|
||||
const insets = useSafeAreaInsets();
|
||||
const navigation = useNavigation();
|
||||
const { getToken, isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
|
||||
@@ -473,10 +475,12 @@ function ConfiguredSettingsRouteScreen() {
|
||||
icon="bell.badge"
|
||||
label="Device Notifications"
|
||||
disabled={
|
||||
!agentAwarenessPlatform.supported ||
|
||||
!agentAwarenessPushAvailable ||
|
||||
notificationStatus === "checking" ||
|
||||
notificationStatus === "unsupported"
|
||||
}
|
||||
subtitle={agentAwarenessPlatform.subtitle}
|
||||
// Only reads as on when this device is actually registered with the
|
||||
// relay; otherwise notifications cannot be delivered regardless of
|
||||
// the local iOS permission.
|
||||
@@ -487,6 +491,7 @@ function ConfiguredSettingsRouteScreen() {
|
||||
/>
|
||||
<SettingsSwitchRow
|
||||
disabled={
|
||||
!agentAwarenessPlatform.supported ||
|
||||
!agentAwarenessPushAvailable ||
|
||||
!isLoaded ||
|
||||
liveActivityStatus === "checking" ||
|
||||
@@ -494,6 +499,7 @@ function ConfiguredSettingsRouteScreen() {
|
||||
}
|
||||
icon="bolt.circle"
|
||||
label="Live Activity Updates"
|
||||
subtitle={agentAwarenessPlatform.subtitle}
|
||||
// Same gate: a saved preference is meaningless until the device
|
||||
// registration the relay needs to push updates has succeeded.
|
||||
value={
|
||||
|
||||
@@ -11,6 +11,7 @@ export function SettingsSwitchRow(props: {
|
||||
readonly disabled?: boolean;
|
||||
readonly icon: SymbolName;
|
||||
readonly label: string;
|
||||
readonly subtitle?: string;
|
||||
readonly value: boolean;
|
||||
readonly onValueChange: (value: boolean) => void;
|
||||
}) {
|
||||
@@ -27,7 +28,12 @@ export function SettingsSwitchRow(props: {
|
||||
}
|
||||
>
|
||||
<SymbolView name={props.icon} size={22} tintColor={icon} type="monochrome" weight="regular" />
|
||||
<Text className="flex-1 text-lg text-foreground">{props.label}</Text>
|
||||
<View className="min-w-0 flex-1">
|
||||
<Text className="text-lg text-foreground">{props.label}</Text>
|
||||
{props.subtitle ? (
|
||||
<Text className="text-sm text-foreground-muted">{props.subtitle}</Text>
|
||||
) : null}
|
||||
</View>
|
||||
<Switch
|
||||
disabled={props.disabled}
|
||||
ios_backgroundColor={track}
|
||||
|
||||
Reference in new issue
Block a user