Commit 195a9781 authored by JC Brand's avatar JC Brand

Use an event instead of an override

parent 5e97db95
...@@ -294,6 +294,25 @@ Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_: ...@@ -294,6 +294,25 @@ Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_:
// Your code here... // Your code here...
}); });
privateChatsAutoJoined
~~~~~~~~~~~~~~~~~~~~~~
Emitted once any private chats have been automatically joined as specified by
the _`auto_join_private_chats` settings.
.. code-block:: javascript
_converse.api.listen.on('privateChatsAutoJoined', function () { ... });
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_.
.. code-block:: javascript
_converse.api.waitUntil('privateChatsAutoJoined').then(function () {
// Your code here...
});
reconnecting reconnecting
~~~~~~~~~~~~ ~~~~~~~~~~~~
...@@ -311,24 +330,14 @@ have to be registered anew. ...@@ -311,24 +330,14 @@ have to be registered anew.
_converse.api.listen.on('reconnected', function () { ... }); _converse.api.listen.on('reconnected', function () { ... });
registeredGlobalEventHandlers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
privateChatsAutoJoined Called once Converse has registered its global event handlers (for events such
~~~~~~~~~~~~~~~~~~~~~~ as window resize or unload).
Emitted once any private chats have been automatically joined as specified by Plugins can listen to this event as cue to register their own global event
the _`auto_join_private_chats` settings. handlers.
.. code-block:: javascript
_converse.api.listen.on('privateChatsAutoJoined', function () { ... });
Also available as an `ES2015 Promise <http://es6-features.org/#PromiseUsage>`_.
.. code-block:: javascript
_converse.api.waitUntil('privateChatsAutoJoined').then(function () {
// Your code here...
});
roomsAutoJoined roomsAutoJoined
--------------- ---------------
......
...@@ -726,6 +726,7 @@ ...@@ -726,6 +726,7 @@
if( document[hidden] !== undefined ) { if( document[hidden] !== undefined ) {
_.partial(_converse.saveWindowState, _, hidden)({type: document[hidden] ? "blur" : "focus"}); _.partial(_converse.saveWindowState, _, hidden)({type: document[hidden] ? "blur" : "focus"});
} }
_converse.emit('registeredGlobalEventHandlers');
}; };
this.enableCarbons = function () { this.enableCarbons = function () {
......
...@@ -52,16 +52,6 @@ ...@@ -52,16 +52,6 @@
// //
// New functions which don't exist yet can also be added. // New functions which don't exist yet can also be added.
registerGlobalEventHandlers () {
const { _converse } = this.__super__;
window.addEventListener("resize", _.debounce(function (ev) {
if (_converse.connection.connected) {
_converse.chatboxviews.trimChats();
}
}, 200));
return this.__super__.registerGlobalEventHandlers.apply(this, arguments);
},
ChatBox: { ChatBox: {
initialize () { initialize () {
this.__super__.initialize.apply(this, arguments); this.__super__.initialize.apply(this, arguments);
...@@ -541,6 +531,15 @@ ...@@ -541,6 +531,15 @@
_converse.emit('minimizedChatsInitialized'); _converse.emit('minimizedChatsInitialized');
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL)); }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
_converse.on('registeredGlobalEventHandlers', function () {
window.addEventListener("resize", _.debounce(function (ev) {
if (_converse.connection.connected) {
_converse.chatboxviews.trimChats();
}
}, 200));
});
_converse.on('controlBoxOpened', function (chatbox) { _converse.on('controlBoxOpened', function (chatbox) {
// Wrapped in anon method because at scan time, chatboxviews // Wrapped in anon method because at scan time, chatboxviews
// attr not set yet. // attr not set yet.
......
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