Get rid of lodash's invoke method

This commit is contained in:
JC Brand 2023-02-26 19:21:16 +01:00
parent 885a3d92b5
commit 6b365458f5
4 changed files with 4 additions and 6 deletions

View File

@ -1,5 +1,4 @@
import debounce from 'lodash-es/debounce';
import invoke from 'lodash-es/invoke';
import isElement from 'lodash-es/isElement';
import log from '../../log';
import p from '../../utils/parse-helpers';
@ -2342,7 +2341,7 @@ const ChatRoomMixin = {
// each <x/> element pertains to a single user.
const item = x.querySelector('item');
const reason = item ? item.querySelector('reason')?.textContent : undefined;
const actor = item ? invoke(item.querySelector('actor'), 'getAttribute', 'nick') : undefined;
const actor = item ? item.querySelector('actor')?.getAttribute('nick') : undefined;
const message = _converse.muc.disconnect_messages[codes[0]];
const status = codes.includes('301') ? ROOMSTATUS.BANNED : ROOMSTATUS.DISCONNECTED;
this.setDisconnectionState(message, reason, actor, status);

View File

@ -3,7 +3,6 @@ import URI from 'urijs';
import _converse from '../_converse.js';
import dayjs from 'dayjs';
import i18n from '../i18n';
import invoke from 'lodash-es/invoke';
import log from '../../log.js';
import sizzle from 'sizzle';
import u, { setUnloadEvent } from '../../utils/core.js';
@ -112,7 +111,7 @@ export const converse = Object.assign(window.converse || {}, {
}
const plugins = _converse.pluggable.plugins
if (api.settings.get("auto_login") || api.settings.get("keepalive") && invoke(plugins['converse-bosh'], 'enabled')) {
if (api.settings.get("auto_login") || api.settings.get("keepalive") && plugins['converse-bosh']?.enabled()) {
await api.user.login(null, null, true);
}

View File

@ -608,7 +608,7 @@ async function updateDevicesFromStanza (stanza) {
export function registerPEPPushHandler () {
// Add a handler for devices pushed from other connected clients
_converse.connection.addHandler(
async message => {
async (message) => {
try {
if (sizzle(`event[xmlns="${Strophe.NS.PUBSUB}#event"]`, message).length) {
await api.waitUntil('OMEMOInitialized');

View File

@ -1,4 +1,4 @@
import debounce from 'lodash/debounce';
import debounce from 'lodash-es/debounce';
import tplNewDay from "./templates/new-day.js";
import { _converse, api, converse } from '@converse/headless/core';
import { html } from 'lit';