Merge pull request #3071 from dpalou/MOBILE-3833

Mobile 3833
main
Pau Ferrer Ocaña 2022-01-26 15:25:36 +01:00 committed by GitHub
commit 15d32b6577
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 6 deletions

View File

@ -576,9 +576,13 @@ export class CoreSite {
// Call the WS. // Call the WS.
try { try {
// Send the language to use. Do it after checking cache to prevent losing offline data when changing language. if (method !== 'core_webservice_get_site_info') {
data.moodlewssettinglang = preSets.lang ?? await CoreLang.getCurrentLanguage(); // Send the language to use. Do it after checking cache to prevent losing offline data when changing language.
data.moodlewssettinglang = data.moodlewssettinglang.replace('-', '_'); // Moodle uses underscore instead of dash. // 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<T>(method, data, preSets, wsPreSets); const response = await this.callOrEnqueueRequest<T>(method, data, preSets, wsPreSets);

View File

@ -121,11 +121,16 @@ export class CoreScreenService {
*/ */
watchOrientation(): void { watchOrientation(): void {
// Listen media orientation CSS queries. // Listen media orientation CSS queries.
window.matchMedia('(orientation: portrait)').addEventListener('change', (m) => { const changeListener = (m: MediaQueryListEvent) => {
const orientation = m.matches ? CoreScreenOrientation.PORTRAIT : CoreScreenOrientation.LANDSCAPE; const orientation = m.matches ? CoreScreenOrientation.PORTRAIT : CoreScreenOrientation.LANDSCAPE;
CoreEvents.trigger(CoreEvents.ORIENTATION_CHANGE, { orientation }); CoreEvents.trigger(CoreEvents.ORIENTATION_CHANGE, { orientation });
}); };
const mql = window.matchMedia('(orientation: portrait)');
mql.addEventListener ?
mql.addEventListener('change', changeListener) :
mql.addListener(changeListener);
} }
/** /**

View File

@ -262,7 +262,7 @@ export class CoreSitesProvider {
} }
// Service supported but an error happened. Return error. // 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. // This could be caused by a redirect. Check if it's the case.
const redirect = await CoreUtils.checkRedirect(siteUrl); 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. // We can't be sure if there is a redirect or not. Display cannot connect error.
error.message = Translate.instant('core.cannotconnecttrouble'); 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({ return new CoreSiteError({