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:
parent
4402798dcd
commit
6ac4f2601d
@ -4,6 +4,9 @@
|
|||||||
- #632 Offline and Logout states do not properly update once users start
|
- #632 Offline and Logout states do not properly update once users start
|
||||||
chatting. [chrisuehlinger, jcband]
|
chatting. [chrisuehlinger, jcband]
|
||||||
- #674 Polish translation updated to the current master. [ser]
|
- #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]
|
- Typing (i.e. chat state) notifications are now also sent out from MUC rooms. [jcbrand]
|
||||||
- `ChatRoomView.onChatRoomMessageSubmitted` has been renamed to
|
- `ChatRoomView.onChatRoomMessageSubmitted` has been renamed to
|
||||||
`onMessageSubmitted`, to make it the same as the method on `ChatBoxView`. [jcbrand]
|
`onMessageSubmitted`, to make it the same as the method on `ChatBoxView`. [jcbrand]
|
||||||
|
@ -1041,16 +1041,13 @@
|
|||||||
// <composing> state
|
// <composing> state
|
||||||
var msg = $msg({
|
var msg = $msg({
|
||||||
from: sender_jid,
|
from: sender_jid,
|
||||||
to: this.connection.jid,
|
to: converse.connection.jid,
|
||||||
type: 'chat',
|
type: 'chat',
|
||||||
id: (new Date()).getTime()
|
id: (new Date()).getTime()
|
||||||
}).c('body').c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
|
}).c('composing', {'xmlns': Strophe.NS.CHATSTATES}).tree();
|
||||||
this.chatboxes.onMessage(msg);
|
converse.chatboxes.onMessage(msg);
|
||||||
expect(converse.emit).toHaveBeenCalledWith('message', 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 () {
|
describe("An active notification", function () {
|
||||||
it("is sent when the user opens a chat box", function () {
|
it("is sent when the user opens a chat box", function () {
|
||||||
|
@ -267,10 +267,9 @@
|
|||||||
|
|
||||||
// Test on chat that's not open
|
// Test on chat that's not open
|
||||||
var box = converse_api.chats.get(jid);
|
var box = converse_api.chats.get(jid);
|
||||||
expect(box instanceof Object).toBeTruthy();
|
expect(typeof box === 'undefined').toBeTruthy();
|
||||||
var chatboxview = converse.chatboxviews.get(jid);
|
|
||||||
expect(chatboxview.$el.is(':visible')).toBeFalsy();
|
|
||||||
|
|
||||||
|
var chatboxview = converse.chatboxviews.get(jid);
|
||||||
// Test for single JID
|
// Test for single JID
|
||||||
test_utils.openChatBoxFor(jid);
|
test_utils.openChatBoxFor(jid);
|
||||||
box = converse_api.chats.get(jid);
|
box = converse_api.chats.get(jid);
|
||||||
|
@ -117,12 +117,10 @@
|
|||||||
return null;
|
return null;
|
||||||
} else if (typeof jids === "string") {
|
} else if (typeof jids === "string") {
|
||||||
chatbox = converse.wrappedChatBox(converse.chatboxes.getChatBox(jids, true));
|
chatbox = converse.wrappedChatBox(converse.chatboxes.getChatBox(jids, true));
|
||||||
chatbox.open();
|
|
||||||
return chatbox;
|
return chatbox;
|
||||||
}
|
}
|
||||||
return _.map(jids, function (jid) {
|
return _.map(jids, function (jid) {
|
||||||
chatbox = converse.wrappedChatBox(converse.chatboxes.getChatBox(jid, true));
|
chatbox = converse.wrappedChatBox(converse.chatboxes.getChatBox(jid, true));
|
||||||
chatbox.open();
|
|
||||||
return chatbox;
|
return chatbox;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -138,7 +136,7 @@
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
} else if (typeof jids === "string") {
|
} else if (typeof jids === "string") {
|
||||||
return converse.wrappedChatBox(converse.chatboxes.getChatBox(jids, true));
|
return converse.wrappedChatBox(converse.chatboxes.getChatBox(jids));
|
||||||
}
|
}
|
||||||
return _.map(jids,
|
return _.map(jids,
|
||||||
_.partial(
|
_.partial(
|
||||||
|
@ -83,7 +83,7 @@
|
|||||||
this.model.on('change:status', this.onStatusChanged, this);
|
this.model.on('change:status', this.onStatusChanged, this);
|
||||||
this.model.on('showHelpMessages', this.showHelpMessages, this);
|
this.model.on('showHelpMessages', this.showHelpMessages, this);
|
||||||
this.model.on('sendMessage', this.sendMessage, 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.
|
// XXX: adding the event below to the events map above doesn't work.
|
||||||
// The code that gets executed because of that looks like this:
|
// The code that gets executed because of that looks like this:
|
||||||
// this.$el.on('scroll', '.chat-content', this.markScrolled.bind(this));
|
// this.$el.on('scroll', '.chat-content', this.markScrolled.bind(this));
|
||||||
|
@ -1367,6 +1367,7 @@
|
|||||||
contact_jid = from_bare_jid;
|
contact_jid = from_bare_jid;
|
||||||
resource = from_resource;
|
resource = from_resource;
|
||||||
}
|
}
|
||||||
|
converse.emit('message', message);
|
||||||
// Get chat box, but only create a new one when the message has a body.
|
// 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);
|
chatbox = this.getChatBox(contact_jid, $message.find('body').length > 0);
|
||||||
if (!chatbox) {
|
if (!chatbox) {
|
||||||
@ -1376,7 +1377,6 @@
|
|||||||
return true; // We already have this message stored.
|
return true; // We already have this message stored.
|
||||||
}
|
}
|
||||||
chatbox.createMessage($message, $delay, message);
|
chatbox.createMessage($message, $delay, message);
|
||||||
converse.emit('message', message);
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user