Cleanup
- Move top-level functinos to utils files - Get rid of unused/obsolete overrides - Only import components there where they're used - Bump version in package.json
This commit is contained in:
parent
3bfd60a3df
commit
ccd60f76c3
54
package-lock.json
generated
54
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "converse.js",
|
||||
"version": "7.0.2",
|
||||
"version": "8.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -4495,9 +4495,9 @@
|
|||
}
|
||||
},
|
||||
"@octokit/openapi-types": {
|
||||
"version": "5.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-5.3.2.tgz",
|
||||
"integrity": "sha512-NxF1yfYOUO92rCx3dwvA2onF30Vdlg7YUkMVXkeptqpzA3tRLplThhFleV/UKWFgh7rpKu1yYRbvNDUtzSopKA==",
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-6.0.0.tgz",
|
||||
"integrity": "sha512-CnDdK7ivHkBtJYzWzZm7gEkanA7gKH6a09Eguz7flHw//GacPJLmkHA3f3N++MJmlxD1Fl+mB7B32EEpSCwztQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@octokit/plugin-enterprise-rest": {
|
||||
|
@ -4641,12 +4641,12 @@
|
|||
}
|
||||
},
|
||||
"@octokit/types": {
|
||||
"version": "6.12.2",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.12.2.tgz",
|
||||
"integrity": "sha512-kCkiN8scbCmSq+gwdJV0iLgHc0O/GTPY1/cffo9kECu1MvatLPh9E+qFhfRIktKfHEA6ZYvv6S1B4Wnv3bi3pA==",
|
||||
"version": "6.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.13.0.tgz",
|
||||
"integrity": "sha512-W2J9qlVIU11jMwKHUp5/rbVUeErqelCsO5vW5PKNb7wAXQVUz87Rc+imjlEvpvbH8yUb+KHmv8NEjVZdsdpyxA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@octokit/openapi-types": "^5.3.2"
|
||||
"@octokit/openapi-types": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"@sinonjs/commons": {
|
||||
|
@ -12150,9 +12150,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
|
||||
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
|
||||
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
|
||||
"dev": true
|
||||
},
|
||||
"init-package-json": {
|
||||
|
@ -13759,9 +13759,9 @@
|
|||
}
|
||||
},
|
||||
"hosted-git-info": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.0.1.tgz",
|
||||
"integrity": "sha512-eT7NrxAsppPRQEBSwKSosReE+v8OzABwEScQYk5d4uxaEPlzxTIku7LINXtBGalthkLhJnq5lBI89PfK43zAKg==",
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.0.2.tgz",
|
||||
"integrity": "sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lru-cache": "^6.0.0"
|
||||
|
@ -13898,9 +13898,9 @@
|
|||
}
|
||||
},
|
||||
"semver": {
|
||||
"version": "7.3.4",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz",
|
||||
"integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==",
|
||||
"version": "7.3.5",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
|
||||
"integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lru-cache": "^6.0.0"
|
||||
|
@ -18639,6 +18639,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"object-inspect": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz",
|
||||
"integrity": "sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw==",
|
||||
"dev": true
|
||||
},
|
||||
"object-is": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz",
|
||||
|
@ -19015,9 +19021,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"qs": {
|
||||
"version": "6.10.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.0.tgz",
|
||||
"integrity": "sha512-yjACOWijC6L/kmPZZAsVBNY2zfHSIbpdpL977quseu56/8BZ2LoF5axK2bGhbzhVKt7V9xgWTtpyLbxwIoER0Q==",
|
||||
"version": "6.10.1",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.1.tgz",
|
||||
"integrity": "sha512-M528Hph6wsSVOBiYUnGf+K/7w0hNshs/duGsNXPUCLH5XAqjEtiPGwNONLV0tBH8NoGb0mvD5JubnUTrujKDTg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"side-channel": "^1.0.4"
|
||||
|
@ -21226,14 +21232,6 @@
|
|||
"call-bind": "^1.0.0",
|
||||
"get-intrinsic": "^1.0.2",
|
||||
"object-inspect": "^1.9.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"object-inspect": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz",
|
||||
"integrity": "sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"sigmund": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "converse.js",
|
||||
"version": "7.0.2",
|
||||
"version": "8.0.0",
|
||||
"description": "Browser based XMPP chat client",
|
||||
"browser": "dist/converse.js",
|
||||
"module": "src/converse.js",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@converse/headless",
|
||||
"version": "7.0.2",
|
||||
"version": "8.0.0",
|
||||
"description": "Converse.js Headless build",
|
||||
"author": "cmrd Senya <senya@riseup.net>",
|
||||
"homepage": "https://conversejs.org",
|
||||
|
|
|
@ -8,15 +8,11 @@ import '@converse/headless/plugins/chatboxes/index.js';
|
|||
import ChatBoxViews from './container.js';
|
||||
import { ViewWithAvatar } from 'shared/avatar.js';
|
||||
import { _converse, api, converse } from '@converse/headless/core';
|
||||
import { calculateViewportHeightUnit } from './utils.js';
|
||||
|
||||
import './styles/chats.scss';
|
||||
|
||||
|
||||
function calculateViewportHeightUnit () {
|
||||
const vh = window.innerHeight * 0.01;
|
||||
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
||||
}
|
||||
|
||||
converse.plugins.add('converse-chatboxviews', {
|
||||
dependencies: ['converse-chatboxes', 'converse-vcard'],
|
||||
|
||||
|
|
5
src/plugins/chatboxviews/utils.js
Normal file
5
src/plugins/chatboxviews/utils.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
export function calculateViewportHeightUnit () {
|
||||
const vh = window.innerHeight * 0.01;
|
||||
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import { html } from "lit-html";
|
||||
import 'shared/chat/toolbar.js';
|
||||
import { api } from '@converse/headless/core.js';
|
||||
import { html } from "lit-html";
|
||||
|
||||
export default (o) => {
|
||||
const message_limit = api.settings.get('message_limit');
|
||||
|
|
|
@ -43,14 +43,6 @@ converse.plugins.add('converse-dragresize', {
|
|||
});
|
||||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
ControlBoxView: {
|
||||
renderControlBoxPane () {
|
||||
const result = this.__super__.renderControlBoxPane.apply(this, arguments);
|
||||
this.initDragResize().setDimensions();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'shared/autocomplete/index.js';
|
||||
import BottomPanel from 'plugins/chatview/bottom-panel.js';
|
||||
import debounce from 'lodash/debounce';
|
||||
import tpl_muc_bottom_panel from './templates/muc-bottom-panel.js';
|
||||
|
|
|
@ -7,74 +7,18 @@
|
|||
import '../chatboxviews/index.js';
|
||||
import '../modal.js';
|
||||
import './adhoc-commands.js';
|
||||
import 'shared/chat/chat-content.js';
|
||||
import 'shared/chat/help-messages.js';
|
||||
import 'shared/chat/toolbar.js';
|
||||
import MUCConfigForm from './config-form.js';
|
||||
import MUCPasswordForm from './password-form.js';
|
||||
import MUCView from './muc.js';
|
||||
import log from '@converse/headless/log';
|
||||
import muc_api from './api.js';
|
||||
import { api, converse, _converse } from '@converse/headless/core';
|
||||
import { api, converse } from '@converse/headless/core';
|
||||
import { fetchAndSetMUCDomain } from './utils.js';
|
||||
|
||||
import './styles/muc.scss';
|
||||
|
||||
const { Strophe } = converse.env;
|
||||
|
||||
converse.MUC.VIEWS = {
|
||||
CONFIG: 'config-form',
|
||||
BOOKMARK: 'bookmark-form'
|
||||
}
|
||||
|
||||
function setMUCDomain (domain, controlboxview) {
|
||||
controlboxview.querySelector('converse-rooms-list')
|
||||
.model.save('muc_domain', Strophe.getDomainFromJid(domain));
|
||||
}
|
||||
|
||||
function setMUCDomainFromDisco (controlboxview) {
|
||||
/* Check whether service discovery for the user's domain
|
||||
* returned MUC information and use that to automatically
|
||||
* set the MUC domain in the "Add groupchat" modal.
|
||||
*/
|
||||
function featureAdded (feature) {
|
||||
if (!feature) {
|
||||
return;
|
||||
}
|
||||
if (feature.get('var') === Strophe.NS.MUC) {
|
||||
feature.entity.getIdentity('conference', 'text').then(identity => {
|
||||
if (identity) {
|
||||
setMUCDomain(feature.get('from'), controlboxview);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
api.waitUntil('discoInitialized')
|
||||
.then(() => {
|
||||
api.listen.on('serviceDiscovered', featureAdded);
|
||||
// Features could have been added before the controlbox was
|
||||
// initialized. We're only interested in MUC
|
||||
_converse.disco_entities.each(entity => featureAdded(entity.features.findWhere({ 'var': Strophe.NS.MUC })));
|
||||
})
|
||||
.catch(e => log.error(e));
|
||||
}
|
||||
|
||||
function fetchAndSetMUCDomain (controlboxview) {
|
||||
if (controlboxview.model.get('connected')) {
|
||||
if (!controlboxview.querySelector('converse-rooms-list').model.get('muc_domain')) {
|
||||
if (api.settings.get('muc_domain') === undefined) {
|
||||
setMUCDomainFromDisco(controlboxview);
|
||||
} else {
|
||||
setMUCDomain(api.settings.get('muc_domain'), controlboxview);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// function openChatRoomFromURIClicked (ev) {
|
||||
// ev.preventDefault();
|
||||
// api.rooms.open(ev.target.href);
|
||||
// }
|
||||
|
||||
converse.plugins.add('converse-muc-views', {
|
||||
/* Dependencies are other plugins which might be
|
||||
* overridden or relied upon, and therefore need to be loaded before
|
||||
|
@ -90,17 +34,6 @@ converse.plugins.add('converse-muc-views', {
|
|||
*/
|
||||
dependencies: ['converse-modal', 'converse-controlbox', 'converse-chatview'],
|
||||
|
||||
overrides: {
|
||||
ControlBoxView: {
|
||||
renderControlBoxPane () {
|
||||
this.__super__.renderControlBoxPane.apply(this, arguments);
|
||||
if (api.settings.get('allow_muc')) {
|
||||
this.renderRoomsPanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
initialize () {
|
||||
const { _converse } = this;
|
||||
|
||||
|
@ -127,21 +60,10 @@ converse.plugins.add('converse-muc-views', {
|
|||
}
|
||||
});
|
||||
|
||||
_converse.MUCConfigForm = MUCConfigForm;
|
||||
_converse.MUCPasswordForm = MUCPasswordForm;
|
||||
_converse.ChatRoomView = MUCView;
|
||||
|
||||
Object.assign(_converse.api, muc_api);
|
||||
|
||||
/************************ BEGIN Event Handlers ************************/
|
||||
api.listen.on('chatBoxViewsInitialized', () => {
|
||||
// FIXME: Find a new way to implement this
|
||||
// _converse.chatboxviews.delegate('click', 'a.open-chatroom', openChatRoomFromURIClicked);
|
||||
|
||||
// TODO: Remove
|
||||
// _converse.chatboxes.on('add', addView);
|
||||
});
|
||||
|
||||
api.listen.on('clearsession', () => {
|
||||
const view = _converse.chatboxviews.get('controlbox');
|
||||
if (view && view.roomspanel) {
|
||||
|
@ -158,6 +80,5 @@ converse.plugins.add('converse-muc-views', {
|
|||
fetchAndSetMUCDomain(view);
|
||||
view.model.on('change:connected', () => fetchAndSetMUCDomain(view));
|
||||
});
|
||||
/************************ END Event Handlers ************************/
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
import './config-form.js';
|
||||
import './password-form.js';
|
||||
import 'shared/autocomplete/index.js';
|
||||
import BaseChatView from 'shared/chat/baseview.js';
|
||||
import ModeratorToolsModal from 'modals/moderator-tools.js';
|
||||
import log from '@converse/headless/log';
|
||||
|
@ -61,12 +58,6 @@ export default class MUCView extends BaseChatView {
|
|||
}),
|
||||
this
|
||||
);
|
||||
this.notifications = this.querySelector('.chat-content__notifications');
|
||||
this.help_container = this.querySelector('.chat-content__help');
|
||||
|
||||
// Render header as late as possible since it's async and we
|
||||
// want the rest of the DOM elements to be available ASAP.
|
||||
// Otherwise e.g. this.notifications is not yet defined when accessed elsewhere.
|
||||
!this.model.get('hidden') && this.show();
|
||||
}
|
||||
|
||||
|
@ -115,10 +106,6 @@ export default class MUCView extends BaseChatView {
|
|||
return _converse.ChatBoxView.prototype.close.apply(this, arguments);
|
||||
}
|
||||
|
||||
getReason (args) { // eslint-disable-line class-methods-use-this
|
||||
return args.includes(',') ? args.slice(args.indexOf(',') + 1).trim() : null;
|
||||
}
|
||||
|
||||
async destroy () {
|
||||
const messages = [__('Are you sure you want to destroy this groupchat?')];
|
||||
let fields = [
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import { html } from "lit-html";
|
||||
import '../bottom-panel.js';
|
||||
import '../sidebar.js';
|
||||
import 'shared/chat/chat-content.js';
|
||||
import 'shared/chat/help-messages.js';
|
||||
import { _converse } from '@converse/headless/core';
|
||||
import { html } from "lit-html";
|
||||
|
||||
export default (o) => html`
|
||||
<div class="chat-area">
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import '../bottom-panel.js';
|
||||
import '../chatarea.js';
|
||||
import '../config-form.js';
|
||||
import '../destroyed.js';
|
||||
|
@ -6,7 +5,6 @@ import '../disconnected.js';
|
|||
import '../heading.js';
|
||||
import '../nickname-form.js';
|
||||
import '../password-form.js';
|
||||
import '../sidebar.js';
|
||||
import tpl_spinner from 'templates/spinner.js';
|
||||
import { converse } from "@converse/headless/core";
|
||||
import { html } from "lit-html";
|
||||
|
|
|
@ -20,6 +20,52 @@ const COMMAND_TO_ROLE = {
|
|||
'voice': 'participant'
|
||||
};
|
||||
|
||||
|
||||
function setMUCDomain (domain, controlboxview) {
|
||||
controlboxview.querySelector('converse-rooms-list')
|
||||
.model.save('muc_domain', Strophe.getDomainFromJid(domain));
|
||||
}
|
||||
|
||||
function setMUCDomainFromDisco (controlboxview) {
|
||||
/* Check whether service discovery for the user's domain
|
||||
* returned MUC information and use that to automatically
|
||||
* set the MUC domain in the "Add groupchat" modal.
|
||||
*/
|
||||
function featureAdded (feature) {
|
||||
if (!feature) {
|
||||
return;
|
||||
}
|
||||
if (feature.get('var') === Strophe.NS.MUC) {
|
||||
feature.entity.getIdentity('conference', 'text').then(identity => {
|
||||
if (identity) {
|
||||
setMUCDomain(feature.get('from'), controlboxview);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
api.waitUntil('discoInitialized')
|
||||
.then(() => {
|
||||
api.listen.on('serviceDiscovered', featureAdded);
|
||||
// Features could have been added before the controlbox was
|
||||
// initialized. We're only interested in MUC
|
||||
_converse.disco_entities.each(entity => featureAdded(entity.features.findWhere({ 'var': Strophe.NS.MUC })));
|
||||
})
|
||||
.catch(e => log.error(e));
|
||||
}
|
||||
|
||||
export function fetchAndSetMUCDomain (controlboxview) {
|
||||
if (controlboxview.model.get('connected')) {
|
||||
if (!controlboxview.querySelector('converse-rooms-list').model.get('muc_domain')) {
|
||||
if (api.settings.get('muc_domain') === undefined) {
|
||||
setMUCDomainFromDisco(controlboxview);
|
||||
} else {
|
||||
setMUCDomain(api.settings.get('muc_domain'), controlboxview);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function getAutoCompleteListItem (text, input) {
|
||||
input = input.trim();
|
||||
const element = document.createElement('li');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import "./message";
|
||||
import dayjs from 'dayjs';
|
||||
import tpl_new_day from "templates/new_day.js";
|
||||
import tpl_new_day from "./templates/new-day.js";
|
||||
import { CustomElement } from 'shared/components/element.js';
|
||||
import { _converse, api } from "@converse/headless/core";
|
||||
import { html } from 'lit-element';
|
||||
|
|
Loading…
Reference in New Issue
Block a user