MOBILE-4606 remotethemes: Fix styles not loaded in reconnect in offline

main
Dani Palou 2024-05-31 15:33:33 +02:00
parent 3fdc860a82
commit 3d393e7bdc
3 changed files with 14 additions and 3 deletions

View File

@ -151,6 +151,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
{ {
config: this.siteConfig, config: this.siteConfig,
loginSuccessful: this.loginSuccessful, loginSuccessful: this.loginSuccessful,
siteId: this.siteId,
}, },
this.siteId, this.siteId,
); );
@ -190,7 +191,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
if (!this.eventThrown && !this.viewLeft) { if (!this.eventThrown && !this.viewLeft) {
this.eventThrown = true; this.eventThrown = true;
CoreEvents.trigger(CoreEvents.LOGIN_SITE_CHECKED, { config: this.siteConfig }); CoreEvents.trigger(CoreEvents.LOGIN_SITE_CHECKED, { config: this.siteConfig, siteId: this.siteId });
} }
this.isBrowserSSO = CoreLoginHelper.isSSOLoginNeeded(this.siteConfig.typeoflogin); this.isBrowserSSO = CoreLoginHelper.isSSOLoginNeeded(this.siteConfig.typeoflogin);

View File

@ -148,8 +148,15 @@ export class CoreStylesService {
this.removeSite(site.getId()); this.removeSite(site.getId());
}); });
// Load temporary styles when site config is checked in login. // Load temporary styles when site config is checked in login/reconnect.
CoreEvents.on(CoreEvents.LOGIN_SITE_CHECKED, (data) => { CoreEvents.on(CoreEvents.LOGIN_SITE_CHECKED, (data) => {
if (data.siteId) {
// Reconnecting to a site, enable the site styles.
this.enableSiteStyles(data.siteId);
return;
}
this.loadTmpStyles(data.config).catch((error) => { this.loadTmpStyles(data.config).catch((error) => {
this.logger.error('Error loading tmp styles', error); this.logger.error('Error loading tmp styles', error);
}); });
@ -163,8 +170,9 @@ export class CoreStylesService {
return; return;
} }
// The tmp styles are from a site that wasn't added in the end. Just remove them. // User didn't access the site, unload tmp styles and site styles if any.
this.unloadTmpStyles(); this.unloadTmpStyles();
this.clear();
}); });
} }

View File

@ -428,6 +428,7 @@ export type CoreEventActivityDataSentData = {
*/ */
export type CoreEventLoginSiteCheckedData = { export type CoreEventLoginSiteCheckedData = {
config: CoreSitePublicConfigResponse; config: CoreSitePublicConfigResponse;
siteId?: string;
}; };
/** /**
@ -436,6 +437,7 @@ export type CoreEventLoginSiteCheckedData = {
export type CoreEventLoginSiteUncheckedData = { export type CoreEventLoginSiteUncheckedData = {
config?: CoreSitePublicConfigResponse; config?: CoreSitePublicConfigResponse;
loginSuccessful: boolean; loginSuccessful: boolean;
siteId?: string;
}; };
/** /**