1

I have an mobile web based application where I want the user to only use a chat window between them and another person.

I have javascript button that opens a chat window but it does it through the converse.initalize method with all the configuration variables pass to it. On the mobile view the user is only allowed to closed the chat window, there is no minimize option available.

Is there a way to open the chat window again from outside converse.js with out using the initialize method again? It seems a bit heavy since the chat window was open previously I can not see a public api for doing this and I can not see a way of doing this using a plugin since the button event is out side converse.

Martin Naughton
  • 1,476
  • 17
  • 14

2 Answers2

0

There is probably a better way of doing this but in case it helps...

I was trying to decipher the debug log on this and I think that, even though the chat window is closed in Converse, the connection to my ejabberd server isn't disconnected. I tried firing a disconnect when the window close event is fired.

this._converse.on('chatBoxClosed', function (chatbox) {
  this._converse.connection.disconnect();
});

At this point Converse is clever and tried to reopen the window and rejoin the room if auto_reconnect is set to true so I had to turn it off.

window.converse.initialize({
  auto_reconnect: true,
0

Is there a way to open the chat window again from outside converse.js with out using the initialize method again?

Not from outside converse.js, but you can register a plugin for converse.js and open the chat from within the plugin by calling _converse.api.chats.open().

The API is documented here:

https://conversejs.org/docs/html/developer_api.html#the-chats-grouping

JC Brand
  • 2,652
  • 18
  • 18