import { AuthState, User } from 'app/services/user';
import { Component, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';
import { WebSocket } from 'app/services/web-socket';

@Component({
    selector: 'app-{{kebab-name}}',
    styleUrls: ['./app.component.scss'],
    templateUrl: './app.component.pug',
})
export class AppComponent implements OnDestroy {
    public loggedIn: boolean = false;
    private _authSubscription: Subscription;

    constructor(private _ws: WebSocket, private _user: User) {
        this._authSubscription = this._user.authChange.subscribe((loggedInState: AuthState) => {
            this.loggedIn = loggedInState === AuthState.LoggedIn;
        });
    }

    public ngOnDestroy(): void {
        this._authSubscription.unsubscribe();
    }
}
