Skip to content

Commit

Permalink
if isConsented, don't re-prompt for optional permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
JGreenlee committed Oct 9, 2024
1 parent 655f843 commit 03dd1f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion www/js/onboarding/onboardingHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function getPendingOnboardingState(): Promise<OnboardingState> {
);
}

async function readConsented() {
export async function readConsented() {

Check warning on line 76 in www/js/onboarding/onboardingHelper.ts

View check run for this annotation

Codecov / codecov/patch

www/js/onboarding/onboardingHelper.ts#L76

Added line #L76 was not covered by tests
return readConsentState().then(isConsented) as Promise<boolean>;
}

Expand Down
8 changes: 3 additions & 5 deletions www/js/usePermissionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) => {

Check warning on line 369 in www/js/usePermissionStatus.ts

View check run for this annotation

Codecov / codecov/patch

www/js/usePermissionStatus.ts#L369

Added line #L369 was not covered by tests
DEVICE_PLATFORM = window['device'].platform.toLowerCase();
DEVICE_VERSION = window['device'].version.split('.')[0];
setupPermissionText();
logDebug('setting up permissions');
createChecklist(hasRequestedNotifs);
createChecklist(isConsented);

Check warning on line 374 in www/js/usePermissionStatus.ts

View check run for this annotation

Codecov / codecov/patch

www/js/usePermissionStatus.ts#L374

Added line #L374 was not covered by tests
});
}
}, [appConfig]);
Expand Down

0 comments on commit 03dd1f0

Please sign in to comment.