From 6170a4eb032a14008b2f4a63a73fd2f500269cf5 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 26 Apr 2018 06:43:38 +0200 Subject: [PATCH] Service also stores first message ID --- assets/js/components/conversations/service.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/assets/js/components/conversations/service.js b/assets/js/components/conversations/service.js index 13fbff1b..327355b8 100644 --- a/assets/js/components/conversations/service.js +++ b/assets/js/components/conversations/service.js @@ -3,7 +3,7 @@ * * Ensure that the content of the conversations is up to date * - * @author Pierre HUBER + * @author Pierre HUBERT */ ComunicWeb.components.conversations.service = { @@ -19,7 +19,7 @@ ComunicWeb.components.conversations.service = { __serviceCache: false, /** - * @var {Boolean} __serviceLock Specify wether the service is already in use or not + * @var {Boolean} __serviceLock Specify whether the service is already in use or not */ __serviceLock: false, @@ -162,7 +162,9 @@ ComunicWeb.components.conversations.service = { //Extract conversation ID var messages = result[i]; - //We update last message ID with the last message ID + //We update first and last message ID with the last message ID + if(messages[0].ID < this.__serviceCache[i].first_message_id || this.__serviceCache[i].first_message_id == 0) + this.__serviceCache[i].first_message_id = messages[0].ID; this.__serviceCache[i].last_message_id = messages[messages.length-1].ID; //We process each message by calling chat windows script to ask it to add messages @@ -195,6 +197,7 @@ ComunicWeb.components.conversations.service = { //Register conversation this.__serviceCache['conversation-' + conversationID] = { conversationID: conversationID, + first_message_id: 0, last_message_id: 0, };