2020-12-06 20:42:12 +01:00
|
|
|
/**
|
2021-09-17 12:17:43 +02:00
|
|
|
* @copyright The Converse.js developers
|
2020-12-06 20:42:12 +01:00
|
|
|
* @description XEP-0045 Multi-User Chat Views
|
|
|
|
* @license Mozilla Public License (MPLv2)
|
|
|
|
*/
|
2021-02-24 06:35:49 +01:00
|
|
|
import '../chatboxviews/index.js';
|
2021-09-17 12:17:43 +02:00
|
|
|
import 'plugins/modal/index.js';
|
2021-02-16 13:43:13 +01:00
|
|
|
import './adhoc-commands.js';
|
2021-02-24 06:35:49 +01:00
|
|
|
import MUCView from './muc.js';
|
2021-03-26 10:34:51 +01:00
|
|
|
import { api, converse } from '@converse/headless/core';
|
2022-02-14 15:16:51 +01:00
|
|
|
import { clearHistory, fetchAndSetMUCDomain, parseMessageForMUCCommands } from './utils.js';
|
2020-12-06 20:42:12 +01:00
|
|
|
|
2021-04-29 15:18:17 +02:00
|
|
|
import './styles/index.scss';
|
2021-03-19 11:47:13 +01:00
|
|
|
|
2021-03-13 11:37:07 +01:00
|
|
|
converse.MUC.VIEWS = {
|
|
|
|
CONFIG: 'config-form',
|
|
|
|
}
|
|
|
|
|
2020-12-06 20:42:12 +01:00
|
|
|
converse.plugins.add('converse-muc-views', {
|
|
|
|
/* Dependencies are other plugins which might be
|
|
|
|
* overridden or relied upon, and therefore need to be loaded before
|
|
|
|
* this plugin. They are "optional" because they might not be
|
|
|
|
* available, in which case any overrides applicable to them will be
|
|
|
|
* ignored.
|
|
|
|
*
|
|
|
|
* NB: These plugins need to have already been loaded via require.js.
|
|
|
|
*
|
|
|
|
* It's possible to make these dependencies "non-optional".
|
|
|
|
* If the setting "strict_plugin_dependencies" is set to true,
|
|
|
|
* an error will be raised if the plugin is not found.
|
|
|
|
*/
|
2020-12-17 15:01:44 +01:00
|
|
|
dependencies: ['converse-modal', 'converse-controlbox', 'converse-chatview'],
|
2020-12-06 20:42:12 +01:00
|
|
|
|
|
|
|
initialize () {
|
|
|
|
const { _converse } = this;
|
|
|
|
|
|
|
|
// Configuration values for this plugin
|
|
|
|
// ====================================
|
|
|
|
// Refer to docs/source/configuration.rst for explanations of these
|
|
|
|
// configuration settings.
|
|
|
|
api.settings.extend({
|
|
|
|
'auto_list_rooms': false,
|
|
|
|
'cache_muc_messages': true,
|
|
|
|
'locked_muc_nickname': false,
|
|
|
|
'modtools_disable_query': [],
|
|
|
|
'muc_disable_slash_commands': false,
|
|
|
|
'muc_mention_autocomplete_filter': 'contains',
|
|
|
|
'muc_mention_autocomplete_min_chars': 0,
|
|
|
|
'muc_mention_autocomplete_show_avatar': true,
|
|
|
|
'muc_roomid_policy': null,
|
|
|
|
'muc_roomid_policy_hint': null,
|
|
|
|
'roomconfig_whitelist': [],
|
|
|
|
'show_retraction_warning': true,
|
|
|
|
'visible_toolbar_buttons': {
|
|
|
|
'toggle_occupants': true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-12-08 12:54:14 +01:00
|
|
|
_converse.ChatRoomView = MUCView;
|
2020-12-06 20:42:12 +01:00
|
|
|
|
2021-03-01 21:31:57 +01:00
|
|
|
api.listen.on('clearsession', () => {
|
2020-12-06 20:42:12 +01:00
|
|
|
const view = _converse.chatboxviews.get('controlbox');
|
|
|
|
if (view && view.roomspanel) {
|
|
|
|
view.roomspanel.model.destroy();
|
|
|
|
view.roomspanel.remove();
|
|
|
|
delete view.roomspanel;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
api.listen.on('controlBoxInitialized', view => {
|
|
|
|
if (!api.settings.get('allow_muc')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fetchAndSetMUCDomain(view);
|
|
|
|
view.model.on('change:connected', () => fetchAndSetMUCDomain(view));
|
|
|
|
});
|
2021-06-15 09:26:06 +02:00
|
|
|
|
|
|
|
api.listen.on('chatBoxClosed', (model) => {
|
|
|
|
if (model.get('type') === _converse.CHATROOMS_TYPE) {
|
|
|
|
clearHistory(model.get('jid'));
|
|
|
|
}
|
|
|
|
});
|
2022-02-14 15:16:51 +01:00
|
|
|
|
|
|
|
api.listen.on('parseMessageForCommands', parseMessageForMUCCommands);
|
2020-12-06 20:42:12 +01:00
|
|
|
}
|
|
|
|
});
|