Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOBILE-4619 sites: Remove site classes on login unchecked #4109

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/addons/remotethemes/services/remotethemes-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class AddonRemoteThemesHandlerService implements CoreStyleHandler {
* @inheritDoc
*/
async getStyle(siteId: string, config?: CoreSitePublicConfigResponse): Promise<string> {
if (siteId == CoreStylesService.TMP_SITE_ID) {
if (siteId === CoreStylesService.TMP_SITE_ID) {
if (!config) {
return '';
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/features/login/pages/reconnect/reconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {

if (error.loggedout) {
this.cancel();
} else if (error.errorcode == 'forcepasswordchangenotice') {
} else if (error.errorcode === 'forcepasswordchangenotice') {
// Reset password field.
this.credForm.controls.password.reset();
} else if (error.errorcode == 'invalidlogin') {
} else if (error.errorcode === 'invalidlogin') {
this.reconnectAttempts++;
}
} finally {
Expand Down
2 changes: 1 addition & 1 deletion src/core/features/login/pages/site/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class CoreLoginSitePage implements OnInit {
constructor(protected formBuilder: FormBuilder) {}

/**
* Initialize the component.
* @inheritdoc
*/
async ngOnInit(): Promise<void> {
let url = '';
Expand Down
14 changes: 12 additions & 2 deletions src/core/services/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class CoreSitesProvider {
}

/**
* Initialize.
* @inheritdoc
*/
initialize(): void {
// Initialize general site events.
Expand Down Expand Up @@ -160,6 +160,16 @@ export class CoreSitesProvider {
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) => {
if (data.siteId !== CoreSites.getCurrentSiteId()) {
return;
Expand Down Expand Up @@ -647,7 +657,7 @@ export class CoreSitesProvider {
this.currentSite = site;
// Store session.
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.
CoreEvents.trigger(CoreEvents.SITE_UPDATED, info, siteId);
}
Expand Down