Skip to content

Commit

Permalink
Step 23.13: Create UninvitedPipe based on UninvitedFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Kisiela authored and Dotan Simha committed Nov 22, 2016
1 parent 2a2ef70 commit 18e4b26
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/main.ts
Expand Up @@ -28,10 +28,12 @@ import { registerPassword } from '../imports/ui/components/password/password';
import { registerRegister } from '../imports/ui/components/register/register';
import { registerSocially, SociallyNg1Module } from '../imports/ui/components/socially/socially';
import { DisplayNamePipe } from '../imports/ui/filters/displayNamePipe';
import { UninvitedPipe } from '../imports/ui/filters/uninvitedPipe';

@NgModule({
declarations: [
DisplayNamePipe
DisplayNamePipe,
UninvitedPipe
],
imports: [
BrowserModule,
Expand Down
20 changes: 20 additions & 0 deletions imports/ui/filters/uninvitedPipe.ts
@@ -0,0 +1,20 @@
import { Pipe } from '@angular/core';
import * as _ from 'underscore';

const name = 'uninvited';

@Pipe({
name
})
export class UninvitedPipe {
transform(users, party) {
if (!party) {
return false;
}

return users.filter((user) => {
// if not the owner and not invited
return user._id !== party.owner && !_.contains(party.invited, user._id);
});
}
}

0 comments on commit 18e4b26

Please sign in to comment.