diff --git a/js/public/app.js b/js/public/app.js index 0d4bb1d..a582a2a 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -188,9 +188,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' 'unread': val }; - $scope.removeContact(contactObj); - $scope.addContactToFront(contactObj); - + $scope.modifyContact(contactObj); bufferedContacts.push(peerLabel); // Re-set conversation because we reload the element @@ -250,11 +248,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' $scope.contacts.push(ct); }); }; - $scope.addContactToFront = function (ct) { - $scope.$apply(function () { - $scope.contacts.splice(0, 0, ct); - }); - }; + $scope.removeContact = function (ct) { var len = $scope.contacts.length; for (var i=0; i < len; i++) { @@ -268,6 +262,18 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' } }; + $scope.modifyContact = function (ct) { + var len = $scope.contacts.length; + for (var i=0; i < len; i++) { + if ($scope.contacts[i]['nav'] == ct['nav']) { + $scope.apply(function () { + $scope.contacts[i].unread = ct.unread; + $scope.contacts[i].avatar = ct.avatar; + }); + } + } + }; + /* * Conversation messagelist management */