Commit 5d9be107be54f73dc3b633e49774e8d6dfa60491

Authored by OpenWapp Developer
1 parent 3e6018b829

Provide a mechanism to distinguish those messages received from server from thos…

…e being loaded from local

Showing 3 changed files with 4 additions and 1 deletions

app/scripts/collections/history.js View file @ 5d9be10
... ... @@ -137,6 +137,7 @@
137 137 },
138 138  
139 139 _addIncomingMessage: function (message) {
  140 + message.fromRemote = true; // mark as received from the server
140 141 var from = message.get('from');
141 142 this.findOrCreate(from.msisdn, null, function (err, result) {
142 143 var conversation = result.conversation;
app/scripts/models/message.js View file @ 5d9be10
... ... @@ -20,6 +20,8 @@
20 20 };
21 21 },
22 22  
  23 + fromRemote: false,
  24 +
23 25 // Save this message to storage, converting it to the appropriate
24 26 // json format (no from, no meta)
25 27 //
app/scripts/views/conversation.js View file @ 5d9be10
... ... @@ -470,7 +470,7 @@
470 470  
471 471 // Make sure the view is added in the right position
472 472 var found = this._findNextMessageIndex(message);
473   - if (isNotFirstChunk) {
  473 + if (!message.fromRemote && isNotFirstChunk) {
474 474 var messageTimestamp = message.get('meta').date.getTime();
475 475 // This is because the message can come in any order so we force
476 476 // elements after _nextToShow to be visible. Not optimal but working