Skip to content

Commit

Permalink
MOBILE-4362 login: Add do not show again to qr code information
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Oct 3, 2023
1 parent 610534e commit b2a179a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
48 changes: 28 additions & 20 deletions src/core/features/login/services/login-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<img src="assets/img/login/faq_url.png" role="presentation" alt="">';
static readonly FAQ_QRCODE_IMAGE_HTML = '<img src="assets/img/login/faq_qrcode.png" role="presentation" alt="">';

Expand Down Expand Up @@ -1221,26 +1222,33 @@ export class CoreLoginHelperProvider {
* @returns Promise resolved if the user accepts to scan QR.
*/
async showScanQRInstructions(): Promise<void> {
await new Promise<void>((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: '<div class="text-center">'+ CoreLoginHelperProvider.FAQ_QRCODE_IMAGE_HTML + '</div>' },
);
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('');
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/core/features/settings/pages/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down

0 comments on commit b2a179a

Please sign in to comment.