From 71ab092e021f75b6ab2e3aadd5683bbda15727aa Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 22 Oct 2019 15:34:15 +0200 Subject: [PATCH] MOBILE-3026 core: Fix back online message displayed on resume --- src/app/app.component.ts | 13 +++++++++---- src/assets/lang/en.json | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a1d80d530..8316ea5fb 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -115,14 +115,19 @@ export class MoodleMobileApp implements OnInit { this.network.onchange().subscribe(() => { // Execute the callback in the Angular zone, so change detection doesn't stop working. this.zone.run(() => { - const isOnline = this.appProvider.isOnline(); - document.body.classList.toggle('core-offline', !isOnline); - document.body.classList.toggle('core-online', isOnline); + const isOnline = this.appProvider.isOnline(), + hadOfflineMessage = document.body.classList.contains('core-offline'); + + document.body.classList.toggle('core-offline', !isOnline); + + if (isOnline && hadOfflineMessage) { + document.body.classList.add('core-online'); - if (isOnline) { setTimeout(() => { document.body.classList.remove('core-online'); }, 3000); + } else if (!isOnline) { + document.body.classList.remove('core-online'); } }); }); diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index c5e9e5631..20432a540 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1316,7 +1316,7 @@ "core.back": "Back", "core.block.blocks": "Blocks", "core.cancel": "Cancel", - "core.cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle 2.4 or later.", + "core.cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle 3.1 or later.", "core.cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.", "core.captureaudio": "Record audio", "core.capturedimage": "Taken picture.",