Skip to content

Commit

Permalink
Step 16.1: Inject Meteor User and add isOwner method
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha committed Nov 27, 2016
1 parent 9ed00b0 commit d9125de
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client/imports/app/parties/parties-list.component.ts
Expand Up @@ -5,6 +5,7 @@ import { Subscription } from 'rxjs/Subscription';
import { MeteorObservable } from 'meteor-rxjs';
import { PaginationService } from 'ng2-pagination';
import { Counts } from 'meteor/tmeasday:publish-counts';
import { InjectUser } from "angular2-meteor-accounts-ui";

import 'rxjs/add/operator/combineLatest';

Expand All @@ -26,6 +27,7 @@ interface Options extends Pagination {
selector: 'parties-list',
template
})
@InjectUser('user')
export class PartiesListComponent implements OnInit, OnDestroy {
parties: Observable<Party[]>;
partiesSub: Subscription;
Expand All @@ -36,6 +38,7 @@ export class PartiesListComponent implements OnInit, OnDestroy {
partiesSize: number = 0;
autorunSub: Subscription;
location: Subject<string> = new Subject<string>();
user: Meteor.User;

constructor(
private paginationService: PaginationService
Expand Down Expand Up @@ -104,6 +107,10 @@ export class PartiesListComponent implements OnInit, OnDestroy {
this.nameOrder.next(parseInt(nameOrder));
}

isOwner(party: Party): boolean {
return this.user && this.user._id === party.owner;
}

ngOnDestroy() {
this.partiesSub.unsubscribe();
this.optionsSub.unsubscribe();
Expand Down

0 comments on commit d9125de

Please sign in to comment.