Commit be3cbe6d authored by JC Brand's avatar JC Brand

Downgrade dayjs

Due to this bug: https://github.com/iamkun/dayjs/issues/792
parent 06606631
This source diff could not be displayed because it is too large. You can view the blob instead.
import converse from "./converse-core";
import log from "@converse/headless/log";
import sizzle from 'sizzle';
import st from "./utils/stanza";
const { Strophe } = converse.env;
let _converse, api;
Strophe.addNamespace('ADHOC', 'http://jabber.org/protocol/commands');
function parseForCommands (stanza) {
const items = sizzle(`query[xmlns="${Strophe.NS.DISCO_ITEMS}"][node="${Strophe.NS.ADHOC}"] item`, stanza);
return items.map(st.getAttributes)
}
const adhoc_api = {
/**
* The XEP-0050 Ad-Hoc Commands API
*
* This API lets you discover ad-hoc commands available for an entity in the XMPP network.
*
* @namespace api.adhoc
* @memberOf api
*/
adhoc: {
/**
* @method api.adhoc.getCommands
* @param { String } to_jid
*/
async getCommands (to_jid) {
let commands = [];
try {
commands = parseForCommands(await api.disco.items(to_jid, Strophe.NS.ADHOC));
} catch (e) {
if (e === null) {
log.error(`Error: timeout while fetching ad-hoc commands for ${to_jid}`);
} else {
log.error(`Error while fetching ad-hoc commands for ${to_jid}`);
log.error(e);
}
}
return commands;
}
}
}
converse.plugins.add('converse-adhoc', {
dependencies: ["converse-disco"],
initialize () {
_converse = this._converse;
api = _converse.api;
Object.assign(api, adhoc_api);
}
});
export default adhoc_api;
import { BootstrapModal } from "../converse-modal.js";
import { __ } from '@converse/headless/i18n';
import { api } from "@converse/headless/converse-core";
import tpl_muc_commands_modal from "../templates/muc_commands_modal.js";
const { Strophe } = window.converse.env;
export default BootstrapModal.extend({
id: "muc-commands-modal",
initialize () {
this.commands = [];
BootstrapModal.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change', this.render);
this.getCommands();
},
toHTML () {
return tpl_muc_commands_modal(Object.assign(
this.model.toJSON(), {
'display_name': __('Ad-hoc commands for %1$s', this.model.getDisplayName()),
'commands': this.commands
})
);
},
async getCommands () {
this.commands = await api.adhoc.getCommands(Strophe.getDomainFromJid(this.model.get('jid')));
this.render();
}
});
import { BootstrapModal } from "../converse-modal.js";
import { __ } from '@converse/headless/i18n';
import tpl_chatroom_details_modal from "../templates/chatroom_details_modal.js";
export default BootstrapModal.extend({
id: "room-details-modal",
initialize () {
BootstrapModal.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change', this.render);
this.listenTo(this.model.features, 'change', this.render);
this.listenTo(this.model.occupants, 'add', this.render);
this.listenTo(this.model.occupants, 'change', this.render);
},
toHTML () {
return tpl_chatroom_details_modal(Object.assign(
this.model.toJSON(), {
'config': this.model.config.toJSON(),
'display_name': __('Groupchat info for %1$s', this.model.getDisplayName()),
'features': this.model.features.toJSON(),
'num_occupants': this.model.occupants.length,
})
);
}
});
import { __ } from '@converse/headless/i18n';
import { html } from "lit-html";
import { modal_close_button, modal_header_close_button } from "./buttons"
import { repeat } from 'lit-html/directives/repeat.js';
const i18n_commands_found = __('Commands found');
const i18n_no_commands_found = __('No commands found');
const tpl_command = (o, command) => html`
<li class="room-item list-group-item">
<div class="available-chatroom d-flex flex-row">
<a class="open-room available-room w-100"
@click=${o.openRoom}
data-command-node="${command.node}"
data-command-jid="${command.jid}"
data-command-name="${command.name}"
title="${command.name}"
href="#">${command.name || command.jid}</a>
</div>
</li>
`;
export default (o) => html`
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="room-details-modal-label">${o.display_name}</h5>
${modal_header_close_button}
</div>
<div class="modal-body">
<ul class="list-group">
<li class="list-group-item active">${ o.commands.length ? i18n_commands_found : i18n_no_commands_found }:</li>
${repeat(o.commands, item => item.jid, item => tpl_command(o, item))}
</ul>
</div>
<div class="modal-footer">${modal_close_button}</div>
</div>
</div>
`;
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