MOBILE-2431 renotethemes: Fix remote styles not enabled after adding a site
parent
cbd1553438
commit
ddac8483d5
|
@ -54,8 +54,7 @@ export class AddonRemoteThemesModule {
|
|||
load: remoteThemesProvider.preloadSites.bind(remoteThemesProvider)
|
||||
});
|
||||
|
||||
let addingSite,
|
||||
unloadTmpStyles;
|
||||
let addingSite;
|
||||
|
||||
// When a new site is added to the app, add its styles.
|
||||
eventsProvider.on(CoreEventsProvider.SITE_ADDED, (data) => {
|
||||
|
@ -68,9 +67,10 @@ export class AddonRemoteThemesModule {
|
|||
addingSite = false;
|
||||
}
|
||||
|
||||
if (unloadTmpStyles == data.siteId) {
|
||||
// This site had some tmp styles loaded, unload them.
|
||||
// User has logged in, remove tmp styles and enable loaded styles.
|
||||
if (data.siteId == sitesProvider.getCurrentSiteId()) {
|
||||
remoteThemesProvider.unloadTmpStyles();
|
||||
remoteThemesProvider.enable(data.siteId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -86,6 +86,7 @@ export class AddonRemoteThemesModule {
|
|||
|
||||
// Enable styles of current site on login.
|
||||
eventsProvider.on(CoreEventsProvider.LOGIN, (data) => {
|
||||
remoteThemesProvider.unloadTmpStyles();
|
||||
remoteThemesProvider.enable(data.siteId);
|
||||
});
|
||||
|
||||
|
@ -106,10 +107,9 @@ export class AddonRemoteThemesModule {
|
|||
|
||||
// Unload temporary styles when site config is "unchecked" in login.
|
||||
eventsProvider.on(CoreEventsProvider.LOGIN_SITE_UNCHECKED, (data) => {
|
||||
if (data.siteId && data.siteid == addingSite) {
|
||||
if (data.siteId && data.siteId === addingSite) {
|
||||
// The tmp styles are from a site that is being added permanently.
|
||||
// Wait for the final site styles to be loaded before removing the tmp styles so there is no blink effect.
|
||||
unloadTmpStyles = data.siteId;
|
||||
} else {
|
||||
// The tmp styles are from a site that wasn't added in the end. Just remove them.
|
||||
remoteThemesProvider.unloadTmpStyles();
|
||||
|
|
Loading…
Reference in New Issue