diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index b6f17c472..8989abfde 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -576,9 +576,13 @@ export class CoreSite { // Call the WS. try { - // Send the language to use. Do it after checking cache to prevent losing offline data when changing language. - data.moodlewssettinglang = preSets.lang ?? await CoreLang.getCurrentLanguage(); - data.moodlewssettinglang = data.moodlewssettinglang.replace('-', '_'); // Moodle uses underscore instead of dash. + if (method !== 'core_webservice_get_site_info') { + // Send the language to use. Do it after checking cache to prevent losing offline data when changing language. + // Don't send it to core_webservice_get_site_info, that WS is used to check if Moodle version is supported. + data.moodlewssettinglang = preSets.lang ?? await CoreLang.getCurrentLanguage(); + // Moodle uses underscore instead of dash. + data.moodlewssettinglang = data.moodlewssettinglang.replace('-', '_'); + } const response = await this.callOrEnqueueRequest(method, data, preSets, wsPreSets); diff --git a/src/core/services/screen.ts b/src/core/services/screen.ts index 6228f7700..04a0e6917 100644 --- a/src/core/services/screen.ts +++ b/src/core/services/screen.ts @@ -121,11 +121,16 @@ export class CoreScreenService { */ watchOrientation(): void { // Listen media orientation CSS queries. - window.matchMedia('(orientation: portrait)').addEventListener('change', (m) => { + const changeListener = (m: MediaQueryListEvent) => { const orientation = m.matches ? CoreScreenOrientation.PORTRAIT : CoreScreenOrientation.LANDSCAPE; CoreEvents.trigger(CoreEvents.ORIENTATION_CHANGE, { orientation }); - }); + }; + + const mql = window.matchMedia('(orientation: portrait)'); + mql.addEventListener ? + mql.addEventListener('change', changeListener) : + mql.addListener(changeListener); } /** diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index e6538fd4e..032ebcf23 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -262,7 +262,7 @@ export class CoreSitesProvider { } // Service supported but an error happened. Return error. - if (error.errorcode == 'codingerror') { + if (error.errorcode === 'codingerror') { // This could be caused by a redirect. Check if it's the case. const redirect = await CoreUtils.checkRedirect(siteUrl); @@ -272,6 +272,9 @@ export class CoreSitesProvider { // We can't be sure if there is a redirect or not. Display cannot connect error. error.message = Translate.instant('core.cannotconnecttrouble'); } + } else if (error.errorcode === 'invalidrecord') { + // WebService not found, site not supported. + error.message = Translate.instant('core.login.invalidmoodleversion', { $a: CoreSite.MINIMUM_MOODLE_VERSION }); } return new CoreSiteError({