Skip to content

Commit

Permalink
Fix issue with login button in production
Browse files Browse the repository at this point in the history
  • Loading branch information
wil92 committed Aug 30, 2024
1 parent b43fe5b commit 74a3522
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div>
@if (!isLogin) {
@if (isBrowser && !isLogin) {
<button mat-button
(click)='loginAction()'
class='login-button font-bold text-sm'>
Login
</button>
} @else {
} @else if (isBrowser) {
<div class='user-data'>

<button mat-button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Inject, OnInit } from '@angular/core';
import { Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';

import { Store } from '@ngxs/store';

Expand All @@ -14,23 +15,28 @@ export class LoginButtonComponent implements OnInit {

isLogin = false;
me?: User;
isBrowser: boolean;

constructor(
@Inject(WINDOW) private window: Window,
@Inject(ENVIRONMENT) private env: Environment,
private store: Store,
private url: UrlUtilsService,
private loginService: LoginService
private loginService: LoginService,
@Inject(PLATFORM_ID) platformId: string,
) {
this.isBrowser = isPlatformBrowser(platformId);
}

getUserImage() {
return this.url.getUserImage(this.me);
}

ngOnInit(): void {
this.store.select(AuthState.isLogin).subscribe(isLogin => this.isLogin = isLogin);
this.store.select(AuthState.me).subscribe(me => this.me = me);
if (this.isBrowser) {
this.store.select(AuthState.isLogin).subscribe(isLogin => this.isLogin = isLogin);
this.store.select(AuthState.me).subscribe(me => this.me = me);
}
}

loginAction() {
Expand Down

0 comments on commit 74a3522

Please sign in to comment.