aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/app.component.ts
blob: 7dc8ffbfee798700e73b1c26beb1b1408596fe1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {Component, OnInit, Inject} from '@angular/core';
import {UsersService} from './services/users.service';
import {BehaviorSubject} from 'rxjs';
import { DOCUMENT } from '@angular/common';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  standalone: false,
  styleUrl: './app.component.css'
})
export class AppComponent implements OnInit {
    // title = 'ufund-ui';
    currentUser$: BehaviorSubject<string> = new BehaviorSubject<string>("Logged out.");

    constructor(
        private userService: UsersService,
        @Inject(DOCUMENT) private document: Document
    ) {}

    reloadPage() {
        this.document.defaultView?.location.reload();
      }

    ngOnInit() {
        this.userService.getCurrentUserSubject().subscribe(r => {
            this.currentUser$?.next(r
                ? "Logged in as " + r.username
                : "Logged out."
            )
        })
    }

}