fix(privacy): stop telemetry on consent revocation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -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" }}
|
||||
/>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user