Merge pull request #4109 from crazyserver/MOBILE-4619

MOBILE-4619 sites: Remove site classes on login unchecked
main
Dani Palou 2024-07-11 13:36:54 +02:00 committed by GitHub
commit 3400d18792
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 6 deletions

View File

@ -54,7 +54,7 @@ export class AddonRemoteThemesHandlerService implements CoreStyleHandler {
* @inheritDoc * @inheritDoc
*/ */
async getStyle(siteId: string, config?: CoreSitePublicConfigResponse): Promise<string> { async getStyle(siteId: string, config?: CoreSitePublicConfigResponse): Promise<string> {
if (siteId == CoreStylesService.TMP_SITE_ID) { if (siteId === CoreStylesService.TMP_SITE_ID) {
if (!config) { if (!config) {
return ''; return '';
} }

View File

@ -261,10 +261,10 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
if (error.loggedout) { if (error.loggedout) {
this.cancel(); this.cancel();
} else if (error.errorcode == 'forcepasswordchangenotice') { } else if (error.errorcode === 'forcepasswordchangenotice') {
// Reset password field. // Reset password field.
this.credForm.controls.password.reset(); this.credForm.controls.password.reset();
} else if (error.errorcode == 'invalidlogin') { } else if (error.errorcode === 'invalidlogin') {
this.reconnectAttempts++; this.reconnectAttempts++;
} }
} finally { } finally {

View File

@ -79,7 +79,7 @@ export class CoreLoginSitePage implements OnInit {
constructor(protected formBuilder: FormBuilder) {} constructor(protected formBuilder: FormBuilder) {}
/** /**
* Initialize the component. * @inheritdoc
*/ */
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
let url = ''; let url = '';

View File

@ -109,7 +109,7 @@ export class CoreSitesProvider {
} }
/** /**
* Initialize. * @inheritdoc
*/ */
initialize(): void { initialize(): void {
// Initialize general site events. // Initialize general site events.
@ -160,6 +160,16 @@ export class CoreSitesProvider {
CoreHTMLClasses.addSiteUrlClass(data.config.httpswwwroot); CoreHTMLClasses.addSiteUrlClass(data.config.httpswwwroot);
}); });
// Unload temporary styles when site config is "unchecked" in login.
CoreEvents.on(CoreEvents.LOGIN_SITE_UNCHECKED, ({ loginSuccessful }) => {
if (loginSuccessful) {
// The classes are already added in LOGIN_SITE_CHECKED.
return;
}
CoreHTMLClasses.removeSiteClasses();
});
CoreEvents.on(CoreEvents.SITE_UPDATED, async (data) => { CoreEvents.on(CoreEvents.SITE_UPDATED, async (data) => {
if (data.siteId !== CoreSites.getCurrentSiteId()) { if (data.siteId !== CoreSites.getCurrentSiteId()) {
return; return;
@ -647,7 +657,7 @@ export class CoreSitesProvider {
this.currentSite = site; this.currentSite = site;
// Store session. // Store session.
await this.login(siteId); await this.login(siteId);
} else if (this.currentSite && this.currentSite.getId() == siteId) { } else if (this.currentSite && this.currentSite.getId() === siteId) {
// Current site has just been updated, trigger the event. // Current site has just been updated, trigger the event.
CoreEvents.trigger(CoreEvents.SITE_UPDATED, info, siteId); CoreEvents.trigger(CoreEvents.SITE_UPDATED, info, siteId);
} }