Added unsubscribe to community logo subscription.

This commit is contained in:
Christian Scheible
2017-06-16 12:34:17 +02:00
parent f4dba7879b
commit 8c16918728
4 changed files with 100 additions and 92 deletions

View File

@@ -22,11 +22,11 @@
<!-- Copyright -->
<ds-comcol-page-content
[content]="(collectionData.payload | async)?.copyrightText"
[hasInnerHtml]="true">>
[hasInnerHtml]="true">
</ds-comcol-page-content>
<!-- Licence -->
<ds-comcol-page-content
[content]="(collectionData.payload | async)?.license"
[title]="'collection.page.license'">>
[title]="'collection.page.license'">
</ds-comcol-page-content>
</div>

View File

@@ -16,7 +16,7 @@
[content]="(communityData.payload | async)?.sidebarText"
[hasInnerHtml]="true"
[title]="'community.page.news'">
</ds-comcol-page-content >
</ds-comcol-page-content>
<!-- Copyright -->
<ds-comcol-page-content
[content]="(communityData.payload | async)?.copyrightText"

View File

@@ -1,19 +1,21 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { Community } from "../core/shared/community.model";
import { Bitstream } from "../core/shared/bitstream.model";
import { RemoteData } from "../core/data/remote-data";
import { CommunityDataService } from "../core/data/community-data.service";
import { Subscription } from "rxjs/Subscription";
@Component({
selector: 'ds-community-page',
styleUrls: ['./community-page.component.css'],
templateUrl: './community-page.component.html',
})
export class CommunityPageComponent implements OnInit {
export class CommunityPageComponent implements OnInit, OnDestroy {
communityData: RemoteData<Community>;
logoData: RemoteData<Bitstream>;
private subs: Subscription[] = [];
constructor(
private communityDataService: CommunityDataService,
@@ -24,12 +26,16 @@ export class CommunityPageComponent implements OnInit {
ngOnInit(): void {
this.route.params.subscribe((params: Params) => {
this.communityData = this.communityDataService.findById(params['id'])
this.communityData.payload
.subscribe(community => this.logoData = community.logo);
this.communityData = this.communityDataService.findById(params['id']);
this.subs.push(this.communityData.payload
.subscribe(community => this.logoData = community.logo));
});
}
ngOnDestroy(): void {
this.subs.forEach(sub => sub.unsubscribe());
}
universalInit() {
}
}

View File

@@ -1,4 +1,5 @@
export const COMMUNITIES = [
export const COMMUNITIES = {
"communities": [
{
"name": "Community 1",
"handle": "10673/1",
@@ -84,4 +85,5 @@ export const COMMUNITIES = [
]
}
}
];
]
};