From a54bd58eee2f748d937fbbf26b0ae0142bd106a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20J=C3=A4ger?= Date: Tue, 8 Nov 2016 10:59:48 +0100 Subject: [PATCH] Reset message count and only add new messages on refresh. Fixes nerzhul/ocsms#117 --- js/public/app.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/public/app.js b/js/public/app.js index e8d8f32..ebb8071 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -150,6 +150,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' } $scope.messages = []; + g_lastMsgDate = 0; $.getJSON(OC.generateUrl('/apps/ocsms/get/conversation'), {'phoneNumber': $scope.selectedContact.nav}, function(jsondata, status) { @@ -437,12 +438,12 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile' // Note: we divide by 100 because number compare too large integers if ((id/100) > (g_lastMsgDate/100)) { g_lastMsgDate = id; - } - // Multiplicate ID to permit date to use it properly - $scope.addConversationMessage({'id': id, 'type': msgClass, 'date': new Date(id * 1), 'content': vals['msg']}); - buf = true; - msgCount++; + // Multiplicate ID to permit date to use it properly + $scope.addConversationMessage({'id': id, 'type': msgClass, 'date': new Date(id * 1), 'content': vals['msg']}); + buf = true; + msgCount++; + } }); return [msgCount,buf];