1

(Sorry for my english) Before i'm using converse js 2.0.4, but now i want update converse js to 3.0.2

I read documentation, but i don't understand how i can write and use my methods for chat.

before i make it easy

converse.listen.on('message', function (event, messageXML) {
                if (messageXML.textContent !== "") {
                    var id = messageXML.attributes.from.value.split('/')[0],
                            text = messageXML.textContent;
                    if (scope.chat.partner.jid === id) {
                        scope.chat.messages.push({
                            photo: scope.chat.partner.image,
                            name: scope.chat.partner.fullname,
                            self: false,
                            textContent: text
                        });
                    }
                }
            });

But now converse working with plugins. Please tell me how i can make code above in new version for example.

Jax
  • 1,839
  • 3
  • 18
  • 30
Vestars
  • 21
  • 3

1 Answers1

0

Used this plugin before initialize, and full _converse methods will become public

converse.plugins.add('_converse', {
                    initialize: function () {
                        $window._converse = this._converse;
                    }
                });
Vestars
  • 21
  • 3
  • This isn't really a good idea. The whole idea of restricting the API to plugins is to avoid exposing the `_converse` object to the global scope where other scripts can access it. The `_converse` object should be treated as private and sensitive. It should only be available in whitelisted plugins. – JC Brand Jun 30 '17 at 08:13