1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-07-23 18:05:33 +00:00

Fix date used to retrieve new messages (#265)

Using the conversation read date to check for new messages will retrieve the same message multiple times if the last read date is older than when the new message arrives.  Instead us the last message we have retrieved as the date to check for new messages from.
This commit is contained in:
Greg Ross 2018-07-20 16:47:53 -04:00 committed by Loïc Blot
parent 76d4a9ad1c
commit 2600b743d1
3 changed files with 5 additions and 2 deletions

View File

@ -110,13 +110,14 @@ class SmsController extends Controller {
}
}
$lastRead = $this->convStateMapper->getLast($this->userId);
$lastMessage = $this->smsMapper->getLastTimestamp($this->userId);
$ocversion = \OCP\Util::getVersion();
$photoversion = 1;
if (version_compare($ocversion[0].".".$ocversion[1].".".$ocversion[2], "9.0.0", ">=")) {
$photoversion = 2;
}
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead, "photos" => $photos, "uids" => $uids, "photo_version" => $photoversion));
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead, "lastMessage" => $lastMessage, "photos" => $photos, "uids" => $uids, "photo_version" => $photoversion));
}
/**

View File

@ -16,6 +16,7 @@ var Sms = {
unreadCountNotifStep: 12,
lastUnreadCountAllConv: 0,
lastContactListMsgDate: 0,
lastMessageDate: 0,
originalTitle: document.title,
photoVersion: 1,

View File

@ -126,7 +126,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
$scope.checkNewMessages = function () {
Sms.unreadCountAllConv = 0;
$.getJSON(Sms.generateURL('/front-api/v1/new_messages'),
{'lastDate': Sms.lastContactListMsgDate},
{'lastDate': Sms.lastMessageDate},
function (jsondata, status) {
var bufferedContacts = [];
@ -323,6 +323,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
});
Sms.lastContactListMsgDate = jsondata["lastRead"];
Sms.lastMessageDate = jsondata["lastMessage"];
};
// Return (int) msgCount, (str) htmlConversation