From 03dd1f03c1a3a3614f1a5cd27e0c4d86ec9d75a2 Mon Sep 17 00:00:00 2001 From: Jack Greenlee Date: Wed, 9 Oct 2024 11:45:20 -0400 Subject: [PATCH] if isConsented, don't re-prompt for optional permissions --- www/js/onboarding/onboardingHelper.ts | 2 +- www/js/usePermissionStatus.ts | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/www/js/onboarding/onboardingHelper.ts b/www/js/onboarding/onboardingHelper.ts index 89e05d9e7..54fd0f1c2 100644 --- a/www/js/onboarding/onboardingHelper.ts +++ b/www/js/onboarding/onboardingHelper.ts @@ -73,7 +73,7 @@ export function getPendingOnboardingState(): Promise { ); } -async function readConsented() { +export async function readConsented() { return readConsentState().then(isConsented) as Promise; } diff --git a/www/js/usePermissionStatus.ts b/www/js/usePermissionStatus.ts index 63ee47e55..5781738fd 100644 --- a/www/js/usePermissionStatus.ts +++ b/www/js/usePermissionStatus.ts @@ -5,9 +5,7 @@ import { useTranslation } from 'react-i18next'; import { useAppTheme } from './appTheme'; import { logDebug, logWarn } from './plugin/logger'; import { AlertManager } from './components/AlertBar'; -import { storageGet } from './plugin/storage'; - -const HAS_REQUESTED_NOTIFS_KEY = 'HasRequestedNotificationPermission'; +import { readConsented } from './onboarding/onboardingHelper'; let DEVICE_PLATFORM: 'android' | 'ios'; let DEVICE_VERSION: number; @@ -368,12 +366,12 @@ const usePermissionStatus = () => { //load when ready useEffect(() => { if (appConfig && window['device']?.platform) { - storageGet(HAS_REQUESTED_NOTIFS_KEY).then((hasRequestedNotifs) => { + readConsented().then((isConsented) => { DEVICE_PLATFORM = window['device'].platform.toLowerCase(); DEVICE_VERSION = window['device'].version.split('.')[0]; setupPermissionText(); logDebug('setting up permissions'); - createChecklist(hasRequestedNotifs); + createChecklist(isConsented); }); } }, [appConfig]);