Commit 5bcde6bae25263a6014469eab6440c2239df434f

Authored by Marcelo Puebla
1 parent 757dbe53eb
Exists in develop

Fix

Desuscribo cuando se destruye compoenentes
src/app/modules/pago-electronico/pago-electronico.component.ts
... ... @@ -4,6 +4,7 @@ import { Router } from '@angular/router';
4 4 import { APP_SETTINGS } from 'src/etc/AppSettings';
5 5 import { BsModalService } from 'ngx-bootstrap/modal';
6 6 import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component';
  7 +import { Subscription } from "rxjs";
7 8  
8 9 @Component({
9 10 selector: 'app-pago-electronico',
... ... @@ -12,6 +13,7 @@ import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-f
12 13 })
13 14 export class PagoElectronicoComponent implements OnInit, OnDestroy {
14 15 urlQr = `${APP_SETTINGS.apiImagenes}/qr/${APP_SETTINGS.deploy}/${APP_SETTINGS.codigoP}/tienda/${APP_SETTINGS.terminal}`;
  16 + subscription: Subscription;
15 17  
16 18 constructor(
17 19 private articuloService: ArticuloService,
... ... @@ -28,7 +30,7 @@ export class PagoElectronicoComponent implements OnInit, OnDestroy {
28 30 pedidoAnombreDe: ''
29 31 };
30 32 dataPago.pedidoAnombreDe = '';
31   - this.articuloService.pay(dataPago)
  33 + this.subscription = this.articuloService.pay(dataPago)
32 34 .subscribe((res: any) => {
33 35 this.articuloService.idComanda = res.data;
34 36 this.router.navigate(['mensaje-final']);
... ... @@ -42,6 +44,7 @@ export class PagoElectronicoComponent implements OnInit, OnDestroy {
42 44 }
43 45  
44 46 ngOnDestroy() {
  47 + if (this.subscription) this.subscription.unsubscribe();
45 48 for (let i = 1; i <= this.modalService.getModalsCount(); i++) {
46 49 this.modalService.hide(i);
47 50 }
src/app/modules/pago-tarjeta/pago-tarjeta.component.ts
... ... @@ -3,6 +3,7 @@ import { ArticuloService } from &#39;src/app/services/articulo/articulo.service&#39;;
3 3 import { Router } from '@angular/router';
4 4 import { BsModalService } from 'ngx-bootstrap/modal';
5 5 import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component';
  6 +import { Subscription } from 'rxjs';
6 7  
7 8 @Component({
8 9 selector: 'app-pago-tarjeta',
... ... @@ -11,7 +12,8 @@ import { ErrorFormaPagoComponent } from &#39;src/app/shared/error-forma-pago/error-f
11 12 })
12 13 export class PagoTarjetaComponent implements OnInit, OnDestroy {
13 14 timer: any;
14   - @ViewChild('template', {static: true}) public template: TemplateRef<any>;
  15 + subscription: Subscription;
  16 + @ViewChild('template', { static: true }) public template: TemplateRef<any>;
15 17  
16 18 constructor(
17 19 private articuloService: ArticuloService,
... ... @@ -28,7 +30,7 @@ export class PagoTarjetaComponent implements OnInit, OnDestroy {
28 30 const dataPago = {
29 31 pedidoAnombreDe: ''
30 32 };
31   - this.articuloService.pay(dataPago)
  33 + this.subscription = this.articuloService.pay(dataPago)
32 34 .subscribe((res: any) => {
33 35 this.articuloService.idComanda = res.data;
34 36 this.router.navigate(['mensaje-final']);
... ... @@ -42,6 +44,7 @@ export class PagoTarjetaComponent implements OnInit, OnDestroy {
42 44 }
43 45  
44 46 ngOnDestroy() {
  47 + if (this.subscription) this.subscription.unsubscribe();
45 48 if (this.timer) clearTimeout(this.timer);
46 49 for (let i = 1; i <= this.modalService.getModalsCount(); i++) {
47 50 this.modalService.hide(i);