From 0a47f60f943bfaa128c9bf0c20af11554b3821c7 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 21 Jul 2017 15:01:35 +0200 Subject: [PATCH] Emit new event ``afterMessagesFetched`` --- CHANGES.md | 4 ++++ docs/source/events.rst | 23 +++++++++++++++++++++++ src/converse-chatview.js | 1 + 3 files changed, 28 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 2a050ac52..63a9bc75b 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,10 @@ * [emojione_image_path](https://conversejs.org/docs/html/configurations.html#emojione-image-path) is used to specify from where Emojione will load images for rendering emojis. +### New events +* ['discoInitialized'](https://conversejs.org/docs/html/development.html#discoInitialized) +* ['afterMessagesFetched'](https://conversejs.org/docs/html/development.html#afterMessagesFetched) + ### Code changes - Removed jQuery from `converse-core`, `converse-vcard` and `converse-roomslist`. [jcbrand] - Remove `jquery.easing` from the full build. Was only being used by the diff --git a/docs/source/events.rst b/docs/source/events.rst index a7e967dcb..0620b78a0 100644 --- a/docs/source/events.rst +++ b/docs/source/events.rst @@ -27,6 +27,20 @@ Refer to the :ref:`whitelisted_plugins` setting. Here follows the different events that are emitted: +afterMessagesFetched +~~~~~~~~~~~~~~~~~~~~ + +Emitted whenever a chat box has fetched its messages from ``sessionStorage`` and +**NOT** from the server. + +This event is listened to by the ``converse-mam`` plugin to know when it can +fetch archived messages from the server. + +The event handler is passed the ``Backbone.View`` instance of the relevant chat +box. + +``_converse.on('afterMessagesFetched', function (chatboxview) { ... });`` + cachedRoster ~~~~~~~~~~~~ @@ -121,6 +135,15 @@ When a chat buddy's custom status message has changed. ``_converse.on('contactStatusMessageChanged', function (data) { ... });`` +discoInitialized +~~~~~~~~~~~~~~~~ + +Emitted once the ``converse-disco`` plugin has been initialized and the +``_converse.disco_entities`` collection will be available and populated with at +least the service discovery features of the user's own server. + +``_converse.on('discoInitialized', function () { ... });`` + disconnected ~~~~~~~~~~~~ diff --git a/src/converse-chatview.js b/src/converse-chatview.js index 8869cff3b..e9746d051 100644 --- a/src/converse-chatview.js +++ b/src/converse-chatview.js @@ -290,6 +290,7 @@ // We only start listening for the scroll event after // cached messages have been fetched this.$content.on('scroll', this.markScrolled.bind(this)); + _converse.emit('afterMessagesFetched', this); }, fetchMessages () {