Downgrade dayjs
Due to this bug: https://github.com/iamkun/dayjs/issues/792
This commit is contained in:
parent
0660663161
commit
be3cbe6dc3
1341
package-lock.json
generated
1341
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -77,7 +77,7 @@
|
|||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
"copy-webpack-plugin": "^5.1.1",
|
"copy-webpack-plugin": "^5.1.1",
|
||||||
"css-loader": "^3.5.2",
|
"css-loader": "^3.5.2",
|
||||||
"dayjs": "^1.8.24",
|
"dayjs": "1.8.15",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-plugin-lodash": "^7.1.0",
|
"eslint-plugin-lodash": "^7.1.0",
|
||||||
"exports-loader": "^0.7.0",
|
"exports-loader": "^0.7.0",
|
||||||
|
61
src/headless/converse-adhoc.js
Normal file
61
src/headless/converse-adhoc.js
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
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;
|
32
src/modals/muc-commands.js
Normal file
32
src/modals/muc-commands.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
27
src/modals/muc-details.js
Normal file
27
src/modals/muc-details.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
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,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
41
src/templates/muc_commands_modal.js
Normal file
41
src/templates/muc_commands_modal.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
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>
|
||||||
|
`;
|
Loading…
Reference in New Issue
Block a user