summaryrefslogtreecommitdiff
path: root/addons/im_livechat/static/src
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-07-17 14:50:29 +0000
committerXavier Dubuc <xdu@odoo.com>2020-09-17 13:17:45 +0000
commit96e94287c6518f25dee1579259707a05481de294 (patch)
treef33e3df40d1f058d0cc2453772afa336ca2a44a0 /addons/im_livechat/static/src
parentd654c05f3e06898a5de025c1b830ba29c039f781 (diff)
[FIX] mail: fix "New messages" separator and channel_seen behaviour
- channel_seen is now called even for own message and only when needed - channel_seen is now called with a message_id which transfer the decision of what is seen to the client which makes more sense task-2282235 task-2282248 closes odoo/odoo#57950 X-original-commit: 04edfa50ccea305050d017c4a1996e561bc7bd57 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/im_livechat/static/src')
-rw-r--r--addons/im_livechat/static/src/legacy/public_livechat.js15
-rw-r--r--addons/im_livechat/static/src/models/thread/thread.js6
2 files changed, 8 insertions, 13 deletions
diff --git a/addons/im_livechat/static/src/legacy/public_livechat.js b/addons/im_livechat/static/src/legacy/public_livechat.js
index 35512fca51d..321c46184d3 100644
--- a/addons/im_livechat/static/src/legacy/public_livechat.js
+++ b/addons/im_livechat/static/src/legacy/public_livechat.js
@@ -177,21 +177,22 @@ var LivechatButton = Widget.extend({
* @param {Array} notification
*/
_handleNotification: function (notification) {
- if (this._livechat && (notification[0] === this._livechat.getUUID())) {
- if (notification[1]._type === 'history_command') { // history request
- var cookie = utils.get_cookie(LIVECHAT_COOKIE_HISTORY);
- var history = cookie ? JSON.parse(cookie) : [];
+ const [livechatUUID, notificationData] = notification;
+ if (this._livechat && (livechatUUID === this._livechat.getUUID())) {
+ if (notificationData._type === 'history_command') { // history request
+ const cookie = utils.get_cookie(LIVECHAT_COOKIE_HISTORY);
+ const history = cookie ? JSON.parse(cookie) : [];
session.rpc('/im_livechat/history', {
pid: this._livechat.getOperatorPID()[0],
channel_uuid: this._livechat.getUUID(),
page_history: history,
});
- } else { // normal message
+ } else if ('body' in notificationData) { // normal message
// If message from notif is already in chatter messages, stop handling
- if (this._messages.some(message => message.getID() === notification[1].id)) {
+ if (this._messages.some(message => message.getID() === notificationData.id)) {
return;
}
- this._addMessage(notification[1]);
+ this._addMessage(notificationData);
this._renderMessages();
if (this._chatWindow.isFolded() || !this._chatWindow.isAtBottom()) {
this._livechat.incrementUnreadCounter();
diff --git a/addons/im_livechat/static/src/models/thread/thread.js b/addons/im_livechat/static/src/models/thread/thread.js
index 1ec06246ec7..9f728f62d40 100644
--- a/addons/im_livechat/static/src/models/thread/thread.js
+++ b/addons/im_livechat/static/src/models/thread/thread.js
@@ -17,12 +17,6 @@ registerClassPatchModel('mail.thread', 'im_livechat/static/src/models/thread/thr
*/
convertData(data) {
const data2 = this._super(data);
- if ('last_message_id' in data) {
- if (!data2.messagesAsServerChannel) {
- data2.messagesAsServerChannel = [];
- }
- data2.messagesAsServerChannel.push(['insert', { id: data.last_message_id }]);
- }
if ('livechat_visitor' in data && data.livechat_visitor) {
if (!data2.members) {
data2.members = [];