From a2c2993012d8a574253cffff862508154f208e23 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 1 Jan 2014 17:42:36 -0800 Subject: [PATCH] Tidy up muc state on join/leave --- clientapp/models/muc.js | 3 +++ clientapp/pages/groupchat.js | 4 ++++ public/x-manifest.cache | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clientapp/models/muc.js b/clientapp/models/muc.js index 408a417..ee7a9a5 100644 --- a/clientapp/models/muc.js +++ b/clientapp/models/muc.js @@ -108,6 +108,8 @@ module.exports = HumanModel.define({ if (!this.nick) { this.nick = me.jid.local; } + this.messages.reset(); + this.resources.reset(); client.joinRoom(this.jid, this.nick, { history: { maxstanzas: 50 @@ -116,6 +118,7 @@ module.exports = HumanModel.define({ }); }, leave: function () { + this.resources.reset(); client.leaveRoom(this.jid, this.nick); } }); diff --git a/clientapp/pages/groupchat.js b/clientapp/pages/groupchat.js index 488c5b4..ad5f771 100644 --- a/clientapp/pages/groupchat.js +++ b/clientapp/pages/groupchat.js @@ -20,6 +20,7 @@ module.exports = BasePage.extend({ this.listenTo(this, 'pageunloaded', this.handlePageUnloaded); this.listenTo(this.model.messages, 'change', this.refreshModel); + this.listenTo(this.model.messages, 'reset', this.resetMessages); this.render(); }, @@ -225,5 +226,8 @@ module.exports = BasePage.extend({ refreshModel: function (model) { var existing = this.$('#chat' + model.cid); existing.replaceWith(model.partialTemplateHtml); + }, + resetMessages: function () { + this.$messageList.empty(); } }); diff --git a/public/x-manifest.cache b/public/x-manifest.cache index ec7b339..d55aea1 100644 --- a/public/x-manifest.cache +++ b/public/x-manifest.cache @@ -1,5 +1,5 @@ CACHE MANIFEST -# 0.0.1 1388621918000 +# 0.0.1 1388626859519 CACHE: /app.js