Skip to content

Commit

Permalink
Step 7.31: Use actual ownership of the message
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and darkbasic committed Oct 16, 2017
1 parent 0193703 commit 885af27
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/pages/messages/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class MessagesPage implements OnInit, OnDestroy {
message: string = '';
autoScroller: MutationObserver;
scrollOffset = 0;
senderId: string;

constructor(
navParams: NavParams,
Expand All @@ -26,6 +27,7 @@ export class MessagesPage implements OnInit, OnDestroy {
this.selectedChat = <Chat>navParams.get('chat');
this.title = this.selectedChat.title;
this.picture = this.selectedChat.picture;
this.senderId = Meteor.userId();
}

private get messagesPageContent(): Element {
Expand Down Expand Up @@ -55,8 +57,6 @@ export class MessagesPage implements OnInit, OnDestroy {
}

findMessagesDayGroups() {
let isEven = false;

return Messages.find({
chatId: this.selectedChat._id
}, {
Expand All @@ -67,8 +67,7 @@ export class MessagesPage implements OnInit, OnDestroy {

// Compose missing data that we would like to show in the view
messages.forEach((message) => {
message.ownership = isEven ? 'mine' : 'other';
isEven = !isEven;
message.ownership = this.senderId == message.senderId ? 'mine' : 'other';

return message;
});
Expand Down

0 comments on commit 885af27

Please sign in to comment.