From 9e06b50fd36f73df5161acb303e346d095e10b75 Mon Sep 17 00:00:00 2001 From: Sebastien Hut Date: Mon, 26 Jan 2015 17:54:47 +0100 Subject: [PATCH] Fix: Messages group: the same day, within 5 minutes --- clientapp/models/message.js | 4 ++-- clientapp/pages/chat.js | 2 +- clientapp/pages/groupchat.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clientapp/models/message.js b/clientapp/models/message.js index 4e7c442..e05fb49 100644 --- a/clientapp/models/message.js +++ b/clientapp/models/message.js @@ -238,9 +238,9 @@ var Message = module.exports = HumanModel.define({ }, shouldGroupWith: function (previous) { if (this.type === 'groupchat') { - return previous && previous.from.full === this.from.full; + return previous && previous.from.full === this.from.full && Math.round((this.created - previous.created) / 1000) <= 300 && previous.created.toLocaleDateString() === this.created.toLocaleDateString(); } else { - return previous && previous.from.bare === this.from.bare; + return previous && previous.from.bare === this.from.bare && Math.round((this.created - previous.created) / 1000) <= 300 && previous.created.toLocaleDateString() === this.created.toLocaleDateString(); } } }); diff --git a/clientapp/pages/chat.js b/clientapp/pages/chat.js index 654abb3..e5a060a 100644 --- a/clientapp/pages/chat.js +++ b/clientapp/pages/chat.js @@ -231,9 +231,9 @@ module.exports = BasePage.extend({ } else { newEl = $(model.templateHtml); this.staydown.append(newEl[0]); + this.lastModel = model; } embedIt(newEl); - this.lastModel = model; }, handleAcceptClick: function (e) { e.preventDefault(); diff --git a/clientapp/pages/groupchat.js b/clientapp/pages/groupchat.js index 185d1d4..8c3248e 100644 --- a/clientapp/pages/groupchat.js +++ b/clientapp/pages/groupchat.js @@ -252,9 +252,9 @@ module.exports = BasePage.extend({ } else { newEl = $(model.templateHtml); this.staydown.append(newEl[0]); + this.lastModel = model; } embedIt(newEl); - this.lastModel = model; }, refreshModel: function (model) { var existing = this.$('#chat' + model.cid);