Skip to content

Commit 885af27

Browse files
dotansimhadarkbasic
authored andcommitted
Step 7.31: Use actual ownership of the message
1 parent 0193703 commit 885af27

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/pages/messages/messages.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class MessagesPage implements OnInit, OnDestroy {
1818
message: string = '';
1919
autoScroller: MutationObserver;
2020
scrollOffset = 0;
21+
senderId: string;
2122

2223
constructor(
2324
navParams: NavParams,
@@ -26,6 +27,7 @@ export class MessagesPage implements OnInit, OnDestroy {
2627
this.selectedChat = <Chat>navParams.get('chat');
2728
this.title = this.selectedChat.title;
2829
this.picture = this.selectedChat.picture;
30+
this.senderId = Meteor.userId();
2931
}
3032

3133
private get messagesPageContent(): Element {
@@ -55,8 +57,6 @@ export class MessagesPage implements OnInit, OnDestroy {
5557
}
5658

5759
findMessagesDayGroups() {
58-
let isEven = false;
59-
6060
return Messages.find({
6161
chatId: this.selectedChat._id
6262
}, {
@@ -67,8 +67,7 @@ export class MessagesPage implements OnInit, OnDestroy {
6767

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

7372
return message;
7473
});

0 commit comments

Comments
 (0)