Skip to content

Commit

Permalink
clear timeout, if standby is left (UnchartedBull#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnchartedBull authored and kantlivelong committed May 5, 2021
1 parent 84bbd71 commit 56ca089
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/standby/standby.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';

import { AppService } from '../app.service';
Expand All @@ -17,6 +17,7 @@ export class StandbyComponent implements OnInit {
public connecting = false;
public error = '';
private connectionRetries = 3;
private displaySleepTimeout: number;

public constructor(
private configService: ConfigService,
Expand All @@ -29,7 +30,7 @@ export class StandbyComponent implements OnInit {

public ngOnInit(): void {
if (this.configService.getAutomaticScreenSleep()) {
setTimeout(this.service.turnDisplayOff.bind(this.service), 300000);
this.displaySleepTimeout = setTimeout(this.service.turnDisplayOff.bind(this.service), 300000);
}
}

Expand Down Expand Up @@ -103,13 +104,16 @@ export class StandbyComponent implements OnInit {

private disableStandby(): void {
if (this.configService.getAutomaticScreenSleep()) {
if (this.displaySleepTimeout) {
clearTimeout(this.displaySleepTimeout);
}
this.service.turnDisplayOn();
}
setTimeout((): void => {
this.connecting = false;
this.notificationService.enableNotifications();
this.router.navigate(['/main-screen']);
}, 1300);
}, 1000);
}
}

Expand Down

0 comments on commit 56ca089

Please sign in to comment.