import {Component, OnInit} from '@angular/core';
import {ApiService} from '../service/api.service';
import {isDebug, debug} from '../utility';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit {

  constructor(
      public readonly api: ApiService,
  ) {}

  ngOnInit() {
    if ( !this.api.isAuthenticated || this.api.isPublicUser ) {
      if ( isDebug() ) {
        debug('Forcing authentication...');
        setTimeout(() => {
          this.api.forceRestart();
        }, 2000);
      } else {
        this.api.forceRestart();
      }
    }
  }
}
