Fixes #677 Chatbox does not open after close

Problem was a race condition between hide and show methods.
Solution was to not hide the chat box during the initialize method.
This commit is contained in:
JC Brand 2016-08-12 20:38:39 +00:00
parent 4402798dcd
commit 6ac4f2601d
6 changed files with 12 additions and 15 deletions

View File

@ -4,6 +4,9 @@
- #632 Offline and Logout states do not properly update once users start
chatting. [chrisuehlinger, jcband]
- #674 Polish translation updated to the current master. [ser]
- #677 Chatbox does not open after close. [jcbrand]
- The behavior of `converse.chats.get` has changed. If the chat box is not
already open, then `undefined` will be returned. [jcbrand]
- Typing (i.e. chat state) notifications are now also sent out from MUC rooms. [jcbrand]
- `ChatRoomView.onChatRoomMessageSubmitted` has been renamed to
`onMessageSubmitted`, to make it the same as the method on `ChatBoxView`. [jcbrand]

View File

@ -1041,16 +1041,13 @@
// <composing> state
var msg = $msg({
from: sender_jid,
to: this.connection.jid,
to: converse.connection.jid,
type: 'chat',
id: (new Date()).getTime()
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
this.chatboxes.onMessage(msg);
}).c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
converse.chatboxes.onMessage(msg);
expect(converse.emit).toHaveBeenCalledWith('message', msg);
var chatboxview = this.chatboxviews.get(sender_jid);
expect(chatboxview).toBeDefined();
expect(chatboxview.$el.is(':visible')).toBeFalsy(); // The chat box is not visible
}.bind(converse));
});
describe("An active notification", function () {
it("is sent when the user opens a chat box", function () {

View File

@ -267,10 +267,9 @@
// Test on chat that's not open
var box = converse_api.chats.get(jid);
expect(box instanceof Object).toBeTruthy();
var chatboxview = converse.chatboxviews.get(jid);
expect(chatboxview.$el.is(':visible')).toBeFalsy();
expect(typeof box === 'undefined').toBeTruthy();
var chatboxview = converse.chatboxviews.get(jid);
// Test for single JID
test_utils.openChatBoxFor(jid);
box = converse_api.chats.get(jid);

View File

@ -117,12 +117,10 @@
return null;
} else if (typeof jids === "string") {
chatbox = converse.wrappedChatBox(converse.chatboxes.getChatBox(jids, true));
chatbox.open();
return chatbox;
}
return _.map(jids, function (jid) {
chatbox = converse.wrappedChatBox(converse.chatboxes.getChatBox(jid, true));
chatbox.open();
return chatbox;
});
},
@ -138,7 +136,7 @@
});
return result;
} else if (typeof jids === "string") {
return converse.wrappedChatBox(converse.chatboxes.getChatBox(jids, true));
return converse.wrappedChatBox(converse.chatboxes.getChatBox(jids));
}
return _.map(jids,
_.partial(

View File

@ -83,7 +83,7 @@
this.model.on('change:status', this.onStatusChanged, this);
this.model.on('showHelpMessages', this.showHelpMessages, this);
this.model.on('sendMessage', this.sendMessage, this);
this.render().fetchMessages().insertIntoDOM().hide();
this.render().fetchMessages().insertIntoDOM().afterShown();
// XXX: adding the event below to the events map above doesn't work.
// The code that gets executed because of that looks like this:
// this.$el.on('scroll', '.chat-content', this.markScrolled.bind(this));

View File

@ -1367,6 +1367,7 @@
contact_jid = from_bare_jid;
resource = from_resource;
}
converse.emit('message', message);
// Get chat box, but only create a new one when the message has a body.
chatbox = this.getChatBox(contact_jid, $message.find('body').length > 0);
if (!chatbox) {
@ -1376,7 +1377,6 @@
return true; // We already have this message stored.
}
chatbox.createMessage($message, $delay, message);
converse.emit('message', message);
return true;
},