From c845d419fe9ffcb2b5fe90ee06c5e11e45306108 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 19 Feb 2017 11:03:24 +0000 Subject: [PATCH] Better way of getting a hold onto the chat room view --- src/converse-muc.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/converse-muc.js b/src/converse-muc.js index 117b59d91..338fefe87 100755 --- a/src/converse-muc.js +++ b/src/converse-muc.js @@ -398,10 +398,9 @@ createOccupantsView: function () { /* Create the ChatRoomOccupantsView Backbone.View */ - this.occupantsview = new _converse.ChatRoomOccupantsView({ - 'model': new _converse.ChatRoomOccupants(), - 'attributes': { 'chatroomview': this } // Hack - }); + var model = new _converse.ChatRoomOccupants(); + model.chatroomview = this; + this.occupantsview = new _converse.ChatRoomOccupantsView({'model': model}); var id = b64_sha1('converse.occupants'+_converse.bare_jid+this.model.get('jid')); this.occupantsview.model.browserStorage = new Backbone.BrowserStorage.session(id); this.occupantsview.render(); @@ -1960,11 +1959,7 @@ initialize: function () { this.model.on("add", this.onOccupantAdded, this); var debouncedRenderRoomFeatures = _.debounce(this.renderRoomFeatures, 100); - - // This is an ugly hack (misusing view attributes) - this.chatroomview = this.attributes.chatroomview; - delete this.attributes.chatroomview; - + this.chatroomview = this.model.chatroomview; this.chatroomview.model.on('change:hidden', debouncedRenderRoomFeatures, this); this.chatroomview.model.on('change:mam_enabled', debouncedRenderRoomFeatures, this); this.chatroomview.model.on('change:membersonly', debouncedRenderRoomFeatures, this);