From b2a179a70a694e9526e166c7d62243aea59254bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 3 Oct 2023 10:52:07 +0200 Subject: [PATCH] MOBILE-4362 login: Add do not show again to qr code information --- .../features/login/services/login-helper.ts | 48 +++++++++++-------- src/core/features/settings/pages/dev/dev.ts | 1 + 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts index 368a69a6aa5..bbf4c2810f2 100644 --- a/src/core/features/login/services/login-helper.ts +++ b/src/core/features/login/services/login-helper.ts @@ -53,6 +53,7 @@ export const GET_STARTED_URL = 'https://moodle.com'; export class CoreLoginHelperProvider { static readonly ONBOARDING_DONE = 'onboarding_done'; + static readonly FAQ_QRCODE_INFO_DONE = 'qrcode_info_done'; static readonly FAQ_URL_IMAGE_HTML = ''; static readonly FAQ_QRCODE_IMAGE_HTML = ''; @@ -1221,26 +1222,33 @@ export class CoreLoginHelperProvider { * @returns Promise resolved if the user accepts to scan QR. */ async showScanQRInstructions(): Promise { - await new Promise((resolve, reject) => { - CoreDomUtils.showAlertWithOptions({ - header: Translate.instant('core.login.faqwhereisqrcode'), - message: Translate.instant( - 'core.login.faqwhereisqrcodeanswer', - { $image: CoreLoginHelperProvider.FAQ_QRCODE_IMAGE_HTML }, - ), - buttons: [ - { - text: Translate.instant('core.cancel'), - role: 'cancel', - handler: () => reject(new CoreCanceledError()), - }, - { - text: Translate.instant('core.next'), - handler: () => resolve(), - }, - ], - }); - }); + const dontShowWarning = await CoreConfig.get(CoreLoginHelperProvider.FAQ_QRCODE_INFO_DONE, 0); + if (dontShowWarning) { + return; + } + + const message = Translate.instant( + 'core.login.faqwhereisqrcodeanswer', + { $image: '
'+ CoreLoginHelperProvider.FAQ_QRCODE_IMAGE_HTML + '
' }, + ); + const header = Translate.instant('core.login.faqwhereisqrcode'); + + try { + const dontShowAgain = await CoreDomUtils.showPrompt( + message, + header, + Translate.instant('core.dontshowagain'), + 'checkbox', + { okText: Translate.instant('core.next'), cancelText: Translate.instant('core.cancel') }, + ); + + if (dontShowAgain) { + CoreConfig.set(CoreLoginHelperProvider.FAQ_QRCODE_INFO_DONE, 1); + } + } catch { + // User canceled. + throw new CoreCanceledError(''); + } } /** diff --git a/src/core/features/settings/pages/dev/dev.ts b/src/core/features/settings/pages/dev/dev.ts index c916950cb08..532f59c60c6 100644 --- a/src/core/features/settings/pages/dev/dev.ts +++ b/src/core/features/settings/pages/dev/dev.ts @@ -165,6 +165,7 @@ export class CoreSettingsDevPage implements OnInit { await CoreUserTours.resetTours(); await CoreConfig.delete(CoreLoginHelperProvider.ONBOARDING_DONE); + await CoreConfig.delete(CoreLoginHelperProvider.FAQ_QRCODE_INFO_DONE); CoreDomUtils.showToast('User tours have been reseted'); }