Skip to content
Permalink
Browse files

Step 7.19: Subscribe to 'messages'

  • Loading branch information...
dotansimha authored and DAB0mB committed Nov 3, 2016
1 parent 984f6e8 commit 7818df79421b5e0436d9f329b495e49409cfc30f
Showing with 12 additions and 8 deletions.
  1. +12 −8 src/pages/messages/messages.ts
@@ -57,15 +57,19 @@ export class MessagesPage implements OnInit, OnDestroy {
}

ngOnInit() {
this.messages = Messages.find(
{chatId: this.selectedChat._id},
{sort: {createdAt: 1}}
).map((messages: Message[]) => {
messages.forEach((message: Message) => {
message.ownership = this.senderId == message.senderId ? 'mine' : 'other';
MeteorObservable.subscribe('messages', this.selectedChat._id).subscribe(() => {
MeteorObservable.autorun().subscribe(() => {
this.messages = Messages.find(
{chatId: this.selectedChat._id},
{sort: {createdAt: 1}}
).map((messages: Message[]) => {
messages.forEach((message: Message) => {
message.ownership = this.senderId == message.senderId ? 'mine' : 'other';
});

return messages;
});
});

return messages;
});

this.autoScroller = this.autoScroll();

0 comments on commit 7818df7

Please sign in to comment.
You can’t perform that action at this time.