Commit 9ee5550c authored by JC Brand's avatar JC Brand

inverse: bugfix, when reloading, hidden auto-joined room was displayed

parent 7e62546d
...@@ -345,41 +345,39 @@ ...@@ -345,41 +345,39 @@
}); });
_converse.openChatRoom = function (settings) { _converse.openChatRoom = function (settings) {
/* Creates a new chat room, making sure that certain attributes /* Opens a chat room, making sure that certain attributes
* are correct, for example that the "type" is set to * are correct, for example that the "type" is set to
* "chatroom". * "chatroom".
*/ */
settings = _.extend( settings = _.assign({'type': CHATROOMS_TYPE}, settings);
_.zipObject(ROOM_FEATURES, _.map(ROOM_FEATURES, _.stubFalse)), return _converse.chatboxviews.showChat(settings);
settings
);
return _converse.chatboxviews.showChat(
_.extend({
'affiliation': null,
'connection_status': ROOMSTATUS.DISCONNECTED,
'description': '',
'features_fetched': false,
'roomconfig': {},
'type': CHATROOMS_TYPE,
}, settings)
);
}; };
_converse.ChatRoom = _converse.ChatBox.extend({ _converse.ChatRoom = _converse.ChatBox.extend({
defaults: function () { defaults: function () {
return _.extend(_.clone(_converse.ChatBox.prototype.defaults), { return _.assign(
'type': CHATROOMS_TYPE, _.clone(_converse.ChatBox.prototype.defaults),
// For group chats, we distinguish between generally unread _.zipObject(ROOM_FEATURES, _.map(ROOM_FEATURES, _.stubFalse)),
// messages and those ones that specifically mention the {
// user. // For group chats, we distinguish between generally unread
// // messages and those ones that specifically mention the
// To keep things simple, we reuse `num_unread` from // user.
// _converse.ChatBox to indicate unread messages which //
// mention the user and `num_unread_general` to indicate // To keep things simple, we reuse `num_unread` from
// generally unread messages (which *includes* mentions!). // _converse.ChatBox to indicate unread messages which
'num_unread_general': 0 // mention the user and `num_unread_general` to indicate
}); // generally unread messages (which *includes* mentions!).
'num_unread_general': 0,
'affiliation': null,
'connection_status': ROOMSTATUS.DISCONNECTED,
'description': '',
'features_fetched': false,
'roomconfig': {},
'type': CHATROOMS_TYPE,
}
);
}, },
isUserMentioned: function (message) { isUserMentioned: function (message) {
...@@ -2574,8 +2572,7 @@ ...@@ -2574,8 +2572,7 @@
} }
}, },
openChatRoom: function (ev) { parseRoomDataFromEvent: function (ev) {
ev.preventDefault();
var name, $name, server, $server, jid; var name, $name, server, $server, jid;
if (ev.type === 'click') { if (ev.type === 'click') {
name = $(ev.target).text(); name = $(ev.target).text();
...@@ -2597,13 +2594,18 @@ ...@@ -2597,13 +2594,18 @@
return; return;
} }
} }
_converse.openChatRoom({ return {
'id': jid, 'id': jid,
'jid': jid, 'jid': jid,
'name': name || Strophe.unescapeNode(Strophe.getNodeFromJid(jid)), 'name': name || Strophe.unescapeNode(Strophe.getNodeFromJid(jid)),
'type': CHATROOMS_TYPE, 'type': CHATROOMS_TYPE,
'box_id': b64_sha1(jid) 'box_id': b64_sha1(jid)
}); }
},
openChatRoom: function (ev) {
ev.preventDefault();
_converse.openChatRoom(this.parseRoomDataFromEvent(ev));
}, },
setDomain: function (ev) { setDomain: function (ev) {
......
...@@ -54,6 +54,17 @@ ...@@ -54,6 +54,17 @@
return this.__super__.createChatBox.call(this, jid, attrs); return this.__super__.createChatBox.call(this, jid, attrs);
} }
}, },
RoomsPanel: {
parseRoomDataFromEvent: function (ev) {
/* We set hidden to false for rooms opened manually by the
* user. They should always be shown.
*/
var result = this.__super__.parseRoomDataFromEvent.apply(this, arguments);
result.hidden = false;
return result;
}
},
ChatBoxViews: { ChatBoxViews: {
showChat: function (attrs, force) { showChat: function (attrs, force) {
...@@ -63,7 +74,8 @@ ...@@ -63,7 +74,8 @@
*/ */
var _converse = this.__super__._converse; var _converse = this.__super__._converse;
var chatbox = this.getChatBox(attrs, true); var chatbox = this.getChatBox(attrs, true);
if ((force || !attrs.hidden) && _converse.connection.authenticated) { var hidden = _.isUndefined(attrs.hidden) ? chatbox.get('hidden') : attrs.hidden;
if ((force || !hidden) && _converse.connection.authenticated) {
_.each(_converse.chatboxviews.xget(chatbox.get('id')), hideChat); _.each(_converse.chatboxviews.xget(chatbox.get('id')), hideChat);
chatbox.save({'hidden': false}); chatbox.save({'hidden': false});
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment