Skip to content

Commit

Permalink
Step 15.8: Update the users list reactively
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Dec 14, 2016
1 parent dabcc7c commit b6eb92d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions client/imports/app/parties/party-details.component.ts
Expand Up @@ -43,6 +43,7 @@ export class PartyDetailsComponent implements OnInit, OnDestroy {
this.partySub = MeteorObservable.subscribe('party', this.partyId).subscribe(() => {
MeteorObservable.autorun().subscribe(() => {
this.party = Parties.findOne(this.partyId);
this.getUsers(this.party);
});
});

Expand All @@ -51,15 +52,22 @@ export class PartyDetailsComponent implements OnInit, OnDestroy {
}

this.uninvitedSub = MeteorObservable.subscribe('uninvited', this.partyId).subscribe(() => {
this.users = Users.find({
_id: {
$ne: Meteor.userId()
}
}).zone();
this.getUsers(this.party);
});
});
}

getUsers(party: Party) {
if (party) {
this.users = Users.find({
_id: {
$nin: party.invited || [],
$ne: Meteor.userId()
}
}).zone();
}
}

saveParty() {
if (!Meteor.userId()) {
alert('Please log in to change this party');
Expand Down

0 comments on commit b6eb92d

Please sign in to comment.