fix(privacy): stop telemetry on consent revocation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Dennis V
2026-07-14 06:30:09 +00:00
parent 679475d0a4
commit f9b18a06f3
8 changed files with 114 additions and 46 deletions

View File

@@ -73,14 +73,26 @@ export default function SettingsScreen() {
const { settings, hasBiometrics, updateSettings, lock } = useAuth()
const { notifications, setNotification } = useSettings()
const [osGranted, setOsGranted] = useState<boolean | null>(null)
const [telemetryUpdating, setTelemetryUpdating] = useState(false)
// Telemetry consent: hasTelemetryConsent() returns null (unknown), true, or false.
// We initialise local state from in-memory value; updates call setTelemetryConsent().
const [crashReporting, setCrashReporting] = useState<boolean>(hasTelemetryConsent() ?? false)
const handleCrashReportingToggle = useCallback(async (value: boolean) => {
setCrashReporting(value)
await setTelemetryConsent(value)
setTelemetryUpdating(true)
try {
await setTelemetryConsent(value)
setCrashReporting(value)
} catch {
setCrashReporting(hasTelemetryConsent() ?? false)
Alert.alert(
"Privacy Setting Not Saved",
"Crash reporting is off for this session, but your choice could not be saved. Please try again.",
)
} finally {
setTelemetryUpdating(false)
}
}, [])
// Check OS permission state on first toggle attempt
@@ -193,6 +205,7 @@ export default function SettingsScreen() {
<Switch
value={crashReporting}
onValueChange={handleCrashReportingToggle}
disabled={telemetryUpdating}
trackColor={{ false: "#767577", true: "#22c55e" }}
/>
}