Skip to content

Commit

Permalink
fix(front) unsubscribe !!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
t8g committed Oct 13, 2017
1 parent 98c53eb commit 637e088
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions client/src/app/isari-editor/isari-editor.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LoaderService } from './../loader/loader.service';
import { Component, OnInit, ViewContainerRef, Input, HostListener, Inject } from '@angular/core';
import { Component, OnInit, ViewContainerRef, Input, HostListener, Inject, OnDestroy } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { ActivatedRoute, Router, ParamMap } from '@angular/router';
import { FormGroup } from '@angular/forms';
Expand All @@ -21,6 +21,7 @@ import { PageScrollService, PageScrollInstance, PageScrollConfig } from 'ng2-pag
import { DOCUMENT } from '@angular/platform-browser';

import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { BehaviorSubject } from 'rxjs';
import 'rxjs/add/observable/combineLatest';
import 'rxjs/add/operator/startWith';
Expand All @@ -31,7 +32,7 @@ import { EditLogApiOptions } from '../isari-logs/EditLogApiOptions.class';
templateUrl: './isari-editor.component.html',
styleUrls: ['./isari-editor.component.css']
})
export class IsariEditorComponent implements OnInit {
export class IsariEditorComponent implements OnInit, OnDestroy {
dialogRef: MdDialogRef<ConfirmDialog>;

@Input() id: number;
Expand All @@ -47,6 +48,7 @@ export class IsariEditorComponent implements OnInit {
exist = false;
private errors: any;
organization: string;
sub: Subscription;

// history (logs)
displayHistory = false;
Expand Down Expand Up @@ -96,7 +98,7 @@ export class IsariEditorComponent implements OnInit {

this.route.queryParams.subscribe(({organization}) => this.organization = organization);

Observable.combineLatest(
this.sub = Observable.combineLatest(
$routeParams,
this.userService.getRestrictedFields(),
this.translate.onLangChange
Expand Down Expand Up @@ -166,6 +168,12 @@ export class IsariEditorComponent implements OnInit {
});
}

ngOnDestroy() {
if (this.sub) {
this.sub.unsubscribe();
}
}

@HostListener('window:keydown', ['$event'])
onKeydown($event) {
if (this.pressedSaveShortcut($event)) {
Expand Down

0 comments on commit 637e088

Please sign in to comment.