Skip to content

Commit

Permalink
MOBILE-4741 core: Pass lang parameter when opening IAB too
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalou committed Jan 20, 2025
1 parent 6f1bdec commit 6aff337
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/features/user/services/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { CoreSubscriptions } from '@singletons/subscriptions';
import { AlertButton } from '@ionic/angular';
import { CoreLang } from '@services/lang';
import { CoreUserNullSupportConfig } from '@features/user/classes/support/null-support-config';
import { CoreOpener } from '@singletons/opener';
import { CoreAlerts } from '@services/overlays/alerts';

/**
Expand All @@ -41,10 +40,9 @@ export class CoreUserSupportService {
async contact(options: CoreUserSupportContactOptions = {}): Promise<void> {
const supportConfig = options.supportConfig ?? CoreUserAuthenticatedSupportConfig.forCurrentSite();
const supportPageUrl = supportConfig.getSupportPageUrl();
const autoLoginUrl = await CoreSites.getCurrentSite()?.getAutoLoginUrl(supportPageUrl, false);
const browser = CoreOpener.openInApp(autoLoginUrl ?? supportPageUrl);
const browser = await CoreSites.getCurrentSite()?.openInAppWithAutoLogin(supportPageUrl);

if (supportPageUrl.endsWith('/user/contactsitesupport.php')) {
if (browser && supportPageUrl.endsWith('/user/contactsitesupport.php')) {
this.populateSupportForm(browser, options.subject, options.message);
this.listenSupportFormSubmission(browser, supportConfig.getSupportPageLang());
}
Expand Down Expand Up @@ -121,6 +119,10 @@ export class CoreUserSupportService {
* @param lang Language used in the support page.
*/
protected async listenSupportFormSubmission(browser: InAppBrowserObject, lang: string | null): Promise<void> {
if (!CorePlatform.isMobile()) {
return;
}

const appSuccessMessage = Translate.instant('core.user.supportmessagesent');
const lmsSuccessMessage = lang && await CoreLang.getMessage('core.user.supportmessagesent', lang);
const subscription = browser.on('loadstop').subscribe(async () => {
Expand Down
6 changes: 6 additions & 0 deletions src/core/singletons/opener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ export class CoreOpener {

CoreOpener.setInAppBrowserToolbarColors(options);

if (CoreSites.getCurrentSite()?.containsUrl(url)) {
url = CoreUrl.addParamsToUrl(url, { lang: CoreLang.getCurrentLanguageSync(CoreLangFormat.LMS) }, {
checkAutoLoginUrl: options.originalUrl !== url,
});
}

CoreOpener.iabInstance = InAppBrowser.create(url, '_blank', options);

if (CorePlatform.isMobile()) {
Expand Down

0 comments on commit 6aff337

Please sign in to comment.