Skip to content

Commit

Permalink
Step 7.30: Use actual ownership of the message
Browse files Browse the repository at this point in the history
  • Loading branch information
DAB0mB committed Feb 13, 2017
1 parent baa7c81 commit b3424da
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions client/imports/pages/messages/messages.ts
Expand Up @@ -19,6 +19,7 @@ export class MessagesPage implements OnInit, OnDestroy {
message: string = '';
autoScroller: MutationObserver;
scrollOffset = 0;
senderId: string;

constructor(
navParams: NavParams,
Expand All @@ -27,6 +28,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 @@ -56,8 +58,6 @@ export class MessagesPage implements OnInit, OnDestroy {
}

findMessagesDayGroups() {
let isEven = false;

return Messages.find({
chatId: this.selectedChat._id
}, {
Expand All @@ -68,8 +68,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 b3424da

Please sign in to comment.