diff --git a/src/app/components/current-user/current-user.component.ts b/src/app/components/current-user/current-user.component.ts index d764528aa..259cc6c71 100644 --- a/src/app/components/current-user/current-user.component.ts +++ b/src/app/components/current-user/current-user.component.ts @@ -25,7 +25,7 @@ import { Subscription } from 'rxjs/Rx'; styleUrls: [ './current-user.component.scss' ] }) export class CurrentUserComponent implements OnInit, OnDestroy { - private personSubscription: Subscription; + private subscriptions: Subscription[] = []; user: any = null; @@ -35,14 +35,13 @@ export class CurrentUserComponent implements OnInit, OnDestroy { ) {} ngOnInit() { - this.personSubscription = this.peopleApi.getCurrentPerson() - .subscribe((person: any) => { - this.user = person.entry; - }); + this.subscriptions = this.subscriptions.concat([ + this.peopleApi.getCurrentPerson().subscribe((person: any) => this.user = person.entry) + ]); } ngOnDestroy() { - this.personSubscription.unsubscribe(); + this.subscriptions.forEach(s => s.unsubscribe()); } get userFirstName(): string { diff --git a/src/app/components/favorites/favorites.component.ts b/src/app/components/favorites/favorites.component.ts index 05851e7a8..c1bb59778 100644 --- a/src/app/components/favorites/favorites.component.ts +++ b/src/app/components/favorites/favorites.component.ts @@ -34,7 +34,7 @@ export class FavoritesComponent extends PageComponent implements OnInit, OnDestr @ViewChild(DocumentListComponent) documentList: DocumentListComponent; - private subscriptions: any = []; + private subscriptions: Subscription[] = []; constructor( private router: Router, diff --git a/src/app/components/files/files.component.ts b/src/app/components/files/files.component.ts index a6ac3f17f..651271e02 100644 --- a/src/app/components/files/files.component.ts +++ b/src/app/components/files/files.component.ts @@ -35,15 +35,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { isValidPath = true; private nodePath: PathElement[]; - private onCopyNode: Subscription; - private onRemoveItem: Subscription; - private onCreateFolder: Subscription; - private onEditFolder: Subscription; - private onDeleteNode: Subscription; - private onMoveNode: Subscription; - private onRestoreNode: Subscription; - private onFileUploadComplete: Subscription; - private onToggleFavorite: Subscription; + private subscriptions: Subscription[] = []; constructor( private router: Router, @@ -85,30 +77,21 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { ); }); - this.onCopyNode = nodeActionsService.contentCopied - .subscribe((nodes) => this.onContentCopied(nodes)); - this.onCreateFolder = contentService.folderCreate.subscribe(() => this.load()); - this.onEditFolder = contentService.folderEdit.subscribe(() => this.load()); - this.onDeleteNode = contentManagementService.deleteNode.subscribe(() => this.load()); - this.onMoveNode = contentManagementService.moveNode.subscribe(() => this.load()); - this.onRestoreNode = contentManagementService.restoreNode.subscribe(() => this.load()); - this.onToggleFavorite = contentManagementService.toggleFavorite.subscribe(() => this.load()); - this.onFileUploadComplete = uploadService.fileUploadComplete - .subscribe(file => this.onFileUploadedEvent(file)); - this.onRemoveItem = uploadService.fileUploadDeleted - .subscribe((file) => this.onFileUploadedEvent(file)); + this.subscriptions = this.subscriptions.concat([ + nodeActionsService.contentCopied.subscribe((nodes) => this.onContentCopied(nodes)), + contentService.folderCreate.subscribe(() => this.load()), + contentService.folderEdit.subscribe(() => this.load()), + contentManagementService.deleteNode.subscribe(() => this.load()), + contentManagementService.moveNode.subscribe(() => this.load()), + contentManagementService.restoreNode.subscribe(() => this.load()), + contentManagementService.toggleFavorite.subscribe(() => this.load()), + uploadService.fileUploadComplete.subscribe(file => this.onFileUploadedEvent(file)), + uploadService.fileUploadDeleted.subscribe((file) => this.onFileUploadedEvent(file)) + ]); } ngOnDestroy() { - this.onCopyNode.unsubscribe(); - this.onRemoveItem.unsubscribe(); - this.onCreateFolder.unsubscribe(); - this.onEditFolder.unsubscribe(); - this.onDeleteNode.unsubscribe(); - this.onMoveNode.unsubscribe(); - this.onRestoreNode.unsubscribe(); - this.onFileUploadComplete.unsubscribe(); - this.onToggleFavorite.unsubscribe(); + this.subscriptions.forEach(s => s.unsubscribe()); this.browsingFilesService.onChangeParent.next(null); } diff --git a/src/app/components/layout/layout.component.ts b/src/app/components/layout/layout.component.ts index 6ccbfb3e7..6669d5392 100644 --- a/src/app/components/layout/layout.component.ts +++ b/src/app/components/layout/layout.component.ts @@ -29,19 +29,20 @@ import { BrowsingFilesService } from '../../common/services/browsing-files.servi export class LayoutComponent implements OnInit, OnDestroy { node: MinimalNodeEntryEntity; - browsingFilesSubscription: Subscription; + private subscriptions: Subscription[] = []; constructor( private contentService: ContentService, private browsingFilesService: BrowsingFilesService) {} ngOnInit() { - this.browsingFilesSubscription = this.browsingFilesService.onChangeParent - .subscribe((node: MinimalNodeEntryEntity) => this.node = node); + this.subscriptions.concat([ + this.browsingFilesService.onChangeParent.subscribe((node: MinimalNodeEntryEntity) => this.node = node) + ]); } ngOnDestroy() { - this.browsingFilesSubscription.unsubscribe(); + this.subscriptions.forEach(s => s.unsubscribe()); } canCreateContent(node: MinimalNodeEntryEntity): boolean { diff --git a/src/app/components/recent-files/recent-files.component.ts b/src/app/components/recent-files/recent-files.component.ts index 4abb8692a..6a32a6d6c 100644 --- a/src/app/components/recent-files/recent-files.component.ts +++ b/src/app/components/recent-files/recent-files.component.ts @@ -32,10 +32,7 @@ export class RecentFilesComponent extends PageComponent implements OnInit, OnDes @ViewChild(DocumentListComponent) documentList: DocumentListComponent; - private onDeleteNode: Subscription; - private onMoveNode: Subscription; - private onRestoreNode: Subscription; - private onToggleFavorite: Subscription; + private subscriptions: Subscription[] = []; constructor( private router: Router, @@ -44,17 +41,16 @@ export class RecentFilesComponent extends PageComponent implements OnInit, OnDes } ngOnInit() { - this.onDeleteNode = this.content.deleteNode.subscribe(() => this.refresh()); - this.onMoveNode = this.content.moveNode.subscribe(() => this.refresh()); - this.onRestoreNode = this.content.restoreNode.subscribe(() => this.refresh()); - this.onToggleFavorite = this.content.toggleFavorite.subscribe(() => this.refresh()); + this.subscriptions = this.subscriptions.concat([ + this.content.deleteNode.subscribe(() => this.refresh()), + this.content.moveNode.subscribe(() => this.refresh()), + this.content.restoreNode.subscribe(() => this.refresh()), + this.content.toggleFavorite.subscribe(() => this.refresh()) + ]); } ngOnDestroy() { - this.onDeleteNode.unsubscribe(); - this.onMoveNode.unsubscribe(); - this.onRestoreNode.unsubscribe(); - this.onToggleFavorite.unsubscribe(); + this.subscriptions.forEach(s => s.unsubscribe()); } onNodeDoubleClick(node: MinimalNodeEntryEntity) { diff --git a/src/app/components/shared-files/shared-files.component.ts b/src/app/components/shared-files/shared-files.component.ts index 6e661ef7a..129c885e7 100644 --- a/src/app/components/shared-files/shared-files.component.ts +++ b/src/app/components/shared-files/shared-files.component.ts @@ -33,10 +33,7 @@ export class SharedFilesComponent extends PageComponent implements OnInit, OnDes @ViewChild(DocumentListComponent) documentList: DocumentListComponent; - private onDeleteNode: Subscription; - private onMoveNode: Subscription; - private onRestoreNode: Subscription; - private onToggleFavorite: Subscription; + private subscriptions: Subscription[] = []; constructor( private router: Router, @@ -46,17 +43,16 @@ export class SharedFilesComponent extends PageComponent implements OnInit, OnDes } ngOnInit() { - this.onDeleteNode = this.content.deleteNode.subscribe(() => this.refresh()); - this.onMoveNode = this.content.moveNode.subscribe(() => this.refresh()); - this.onRestoreNode = this.content.restoreNode.subscribe(() => this.refresh()); - this.onToggleFavorite = this.content.toggleFavorite.subscribe(() => this.refresh()); + this.subscriptions = this.subscriptions.concat([ + this.content.deleteNode.subscribe(() => this.refresh()), + this.content.moveNode.subscribe(() => this.refresh()), + this.content.restoreNode.subscribe(() => this.refresh()), + this.content.toggleFavorite.subscribe(() => this.refresh()) + ]); } ngOnDestroy() { - this.onDeleteNode.unsubscribe(); - this.onMoveNode.unsubscribe(); - this.onRestoreNode.unsubscribe(); - this.onToggleFavorite.unsubscribe(); + this.subscriptions.forEach(s => s.unsubscribe()); } onNodeDoubleClick(link: { nodeId?: string }) { diff --git a/src/app/components/sidenav/sidenav.component.ts b/src/app/components/sidenav/sidenav.component.ts index 583c55c73..4cf3d2f2a 100644 --- a/src/app/components/sidenav/sidenav.component.ts +++ b/src/app/components/sidenav/sidenav.component.ts @@ -31,9 +31,10 @@ import { BrowsingFilesService } from '../../common/services/browsing-files.servi }) export class SidenavComponent implements OnInit, OnDestroy { node: MinimalNodeEntryEntity = null; - onChangeParentSubscription: Subscription; navigation = []; + private subscriptions: Subscription[] = []; + constructor( private browsingFilesService: BrowsingFilesService, private contentService: ContentService, @@ -46,14 +47,14 @@ export class SidenavComponent implements OnInit, OnDestroy { } ngOnInit() { - this.onChangeParentSubscription = this.browsingFilesService.onChangeParent - .subscribe((node: MinimalNodeEntryEntity) => { - this.node = node; - }); + this.subscriptions.concat([ + this.browsingFilesService.onChangeParent + .subscribe((node: MinimalNodeEntryEntity) => this.node = node) + ]); } ngOnDestroy() { - this.onChangeParentSubscription.unsubscribe(); + this.subscriptions.forEach(s => s.unsubscribe()); } canCreateContent(parentNode: MinimalNodeEntryEntity): boolean {