Commit d9fcd2be65c8894c3771c5436f5098414121a4d0

Authored by Marcelo Puebla
Exists in develop

Merge branch 'develop' into 'develop'

Develop

See merge request !28
src/app/modules/admin/admin.component.ts
1   -import { Component, OnInit, HostListener } from '@angular/core';
  1 +import { Component, OnInit, HostListener, OnDestroy } from '@angular/core';
2 2 import { Router } from '@angular/router';
3 3  
4 4 @Component({
... ... @@ -7,7 +7,7 @@ import { Router } from '@angular/router';
7 7 styleUrls: ['./admin.component.scss']
8 8 })
9 9  
10   -export class AdminComponent implements OnInit {
  10 +export class AdminComponent implements OnInit, OnDestroy {
11 11 timerReposo: any;
12 12  
13 13 constructor(
... ... @@ -18,15 +18,12 @@ export class AdminComponent implements OnInit {
18 18 this.startTimeOutInactividad();
19 19 }
20 20  
21   - @HostListener('document:click', ['$event'])
22   -
23   - documentClick(event: MouseEvent) {
24   - if (event) {
25   - this.restartTimer();
26   - }
  21 + ngOnDestroy() {
  22 + clearTimeout(this.timerReposo);
27 23 }
28 24  
29   - restartTimer() {
  25 + @HostListener('document:click', ['$event'])
  26 + documentClick(event: MouseEvent) {
30 27 clearTimeout(this.timerReposo);
31 28 this.startTimeOutInactividad();
32 29 }
src/app/modules/cancelar-compra/cancelar-compra.component.ts
1   -import { Component, OnInit } from '@angular/core';
  1 +import { Component, OnInit, OnDestroy } from '@angular/core';
2 2 import { Location } from '@angular/common';
3 3 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
4 4 import { Router } from '@angular/router';
... ... @@ -8,7 +8,8 @@ import { Router } from '@angular/router';
8 8 templateUrl: './cancelar-compra.component.html',
9 9 styleUrls: ['./cancelar-compra.component.scss']
10 10 })
11   -export class CancelarCompraComponent implements OnInit {
  11 +export class CancelarCompraComponent implements OnInit, OnDestroy {
  12 + timer: any;
12 13  
13 14 constructor(
14 15 private location: Location,
... ... @@ -17,11 +18,15 @@ export class CancelarCompraComponent implements OnInit {
17 18 ) { }
18 19  
19 20 ngOnInit() {
20   - setTimeout(() => {
  21 + this.timer = setTimeout(() => {
21 22 this.limpiarCarritoYvolver();
22 23 }, 90000);
23 24 }
24 25  
  26 + ngOnDestroy() {
  27 + clearTimeout(this.timer);
  28 + }
  29 +
25 30 volverPreviousPage() {
26 31 this.location.back();
27 32 }