MOBILE-4081 core: Fix site name not translated in My Courses

main
Dani Palou 2022-11-24 11:13:18 +01:00
parent bc83f62f0b
commit 9076a61493
1 changed files with 14 additions and 12 deletions

View File

@ -958,18 +958,12 @@ export class CoreSite {
// Call the WS.
const initialToken = this.token ?? '';
// Call the WS.
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 = {
...data,
moodlewssettinglang: preSets.lang ?? await CoreLang.getCurrentLanguage(),
};
// Moodle uses underscore instead of dash.
data.moodlewssettinglang = data.moodlewssettinglang.replace('-', '_');
}
// Send the language to use. Do it after checking cache to prevent losing offline data when changing language.
// Moodle uses underscore instead of dash.
data = {
...data,
moodlewssettinglang: (preSets.lang ?? await CoreLang.getCurrentLanguage()).replace('-', '_'),
};
try {
return await this.callOrEnqueueRequest<T>(method, data, preSets, wsPreSets);
@ -988,6 +982,14 @@ export class CoreSite {
}
}
if (error?.errorcode === 'invalidparameter' && method === 'core_webservice_get_site_info') {
// Retry without passing the lang, this parameter isn't supported in 3.4 or older sites
// and we need this WS call to be able to determine if the site is supported or not.
delete data.moodlewssettinglang;
return await this.callOrEnqueueRequest<T>(method, data, preSets, wsPreSets);
}
throw error;
}
}