From 56ca089de74949d9d648733beb69b33af77f272f Mon Sep 17 00:00:00 2001 From: Timon G Date: Tue, 19 May 2020 00:50:10 +0200 Subject: [PATCH] clear timeout, if standby is left (#659) --- src/app/standby/standby.component.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/standby/standby.component.ts b/src/app/standby/standby.component.ts index 40d6721f19..1409236f6c 100644 --- a/src/app/standby/standby.component.ts +++ b/src/app/standby/standby.component.ts @@ -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'; @@ -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, @@ -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); } } @@ -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); } }