Commit a9d28818 authored by JC Brand's avatar JC Brand

Fix disco hierarchy

Previously we kept all entities and their items (which are also
instances of _converse.DiscoEntity) in a flat array.

Instead, we should have a tree-like structure where items are stored
on the relevant entity (and recursively on other items).
parent 77a51cc2
......@@ -30,7 +30,7 @@
"accessor-pairs": "error",
"array-bracket-spacing": "off",
"array-callback-return": "error",
"arrow-body-style": "error",
"arrow-body-style": "off",
"arrow-parens": "error",
"arrow-spacing": "error",
"block-scoped-var": "off",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -550,7 +550,7 @@
_converse.api.disco.getIdentity('pubsub', 'pep', _converse.bare_jid),
_converse.api.disco.supports(Strophe.NS.PUBSUB+'#publish-options', _converse.bare_jid)
]).then((args) => {
resolve(args[0] && (args[1].supported || _converse.allow_public_bookmarks));
resolve(args[0] && (args[1].length || _converse.allow_public_bookmarks));
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
}
......
......@@ -341,8 +341,7 @@
Promise.all(_.map(_.keys(resources), (resource) =>
_converse.api.disco.supports(Strophe.NS.SPOILER, `${contact_jid}/${resource}`)
)).then((results) => {
const supported = _.every(f.map(f.get('supported'))(results));
if (supported) {
if (results.length) {
const html = tpl_spoiler_button(this.model.toJSON());
if (_converse.visible_toolbar_buttons.emoji) {
this.el.querySelector('.toggle-smiley').insertAdjacentHTML('afterEnd', html);
......
This diff is collapsed.
(function (root, factory) {
define(["converse-http-file-upload"], factory);
define(["converse-core"], factory);
}(this, function (converse) {
"use strict";
const { Promise, Strophe, _ } = converse.env;
const u = converse.env.utils;
Strophe.addNamespace('HTTPUPLOAD', 'urn:xmpp:http:upload:0');
converse.plugins.add('converse-http-file-upload', {
/* Plugin dependencies are other plugins which might be
* overridden or relied upon, and therefore need to be loaded before
* this plugin.
*
* If the setting "strict_plugin_dependencies" is set to true,
* an error will be raised if the plugin is not found. By default it's
* false, which means these plugins are only loaded opportunistically.
*
* NB: These plugins need to have already been loaded via require.js.
*/
dependencies: ["converse-chatview"],
overrides: {
ChatBoxView: {
addFileUploadButton (options) {
},
renderToolbar (toolbar, options) {
const { _converse } = this.__super__;
const result = this.__super__.renderToolbar.apply(this, arguments);
// TODO: check results.length
_converse.api.disco.supports(Strophe.NS.HTTPUPLOAD, _converse.domain)
.then(this.addFileUploadButton.bind(this));
return result;
}
}
},
initialize () {
/* The initialize function gets called as soon as the plugin is
* loaded by converse.js's plugin machinery.
*/
const { _converse } = this;
}
});
}));
......@@ -154,8 +154,8 @@
if (this.disable_mam) { return; }
const { _converse } = this.__super__;
_converse.api.disco.supports(Strophe.NS.MAM, _converse.bare_jid).then(
(result) => { // Success
if (result.supported) {
(results) => { // Success
if (result.length) {
const most_recent_msg = utils.getMostRecentMessage(this.model);
if (_.isNil(most_recent_msg)) {
this.fetchArchivedMessages();
......@@ -193,7 +193,7 @@
const { _converse } = this.__super__;
_converse.api.disco.supports(Strophe.NS.MAM, _converse.bare_jid).then(
(result) => { // Success
if (result.supported) {
if (result.length) {
this.fetchArchivedMessages();
}
this.model.save({'mam_initialized': true});
......
......@@ -186,7 +186,7 @@
if (_.isNil(_converse.xmppstatus.get('vcard_updated'))) {
_converse.api.disco.supports(Strophe.NS.VCARD, _converse.domain)
.then((result) => {
if (result.supported) {
if (result.length) {
_converse.api.vcard.get(_converse.bare_jid)
.then((vcard) => _converse.xmppstatus.save(vcard));
}})
......
......@@ -7,24 +7,25 @@ if (typeof define !== 'undefined') {
* --------------------
* Any of the following components may be removed if they're not needed.
*/
"converse-chatview", // Renders standalone chat boxes for single user chat
"converse-controlbox", // The control box
"converse-bookmarks", // XEP-0048 Bookmarks
"converse-roomslist", // Show currently open chat rooms
"converse-mam", // XEP-0313 Message Archive Management
"converse-muc", // XEP-0045 Multi-user chat
"converse-muc-views", // Views related to MUC
"converse-bookmarks", // XEP-0048 Bookmarks
"converse-chatview", // Renders standalone chat boxes for single user chat
"converse-controlbox", // The control box
"converse-dragresize", // Allows chat boxes to be resized by dragging them
"converse-fullscreen",
"converse-headline", // Support for headline messages
"converse-http-file-upload",
"converse-mam", // XEP-0313 Message Archive Management
"converse-minimize", // Allows chat boxes to be minimized
"converse-muc", // XEP-0045 Multi-user chat
"converse-muc-embedded",
"converse-muc-views",
"converse-vcard", // XEP-0054 VCard-temp
"converse-otr", // Off-the-record encryption for one-on-one messages
"converse-register", // XEP-0077 In-band registration
"converse-ping", // XEP-0199 XMPP Ping
"converse-notification",// HTML5 Notifications
"converse-minimize", // Allows chat boxes to be minimized
"converse-dragresize", // Allows chat boxes to be resized by dragging them
"converse-headline", // Support for headline messages
"converse-fullscreen"
"converse-muc-views", // Views related to MUC
"converse-notification", // HTML5 Notifications
"converse-otr", // Off-the-record encryption for one-on-one messages
"converse-ping", // XEP-0199 XMPP Ping
"converse-register", // XEP-0077 In-band registration
"converse-roomslist", // Show currently open chat rooms
"converse-vcard", // XEP-0054 VCard-temp
/* END: Removable components */
], function (converse) {
return converse;
......
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