Commit 631b9bb4 authored by JC Brand's avatar JC Brand

Use the settings API for setting and getting config settings

This is an initial step towards no longer storing and accessing settings
directly via the `_converse` object
parent 8d816373
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
## 7.0.0 (Unreleased) ## 7.0.0 (Unreleased)
*Note for plugin authors:*
configuration settings should now be accessed via `_converse.api.settings.get` and not directly on the `_converse` object.
Soon we'll deprecate the latter, so prepare now.
- #1313: Stylistic improvements to the send button - #1313: Stylistic improvements to the send button
- #1490: Busy-loop when fetching registration form fails - #1490: Busy-loop when fetching registration form fails
- #1535: Add option to destroy a MUC - #1535: Add option to destroy a MUC
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
_converse.idle_seconds = 0; // Usually initialized by registerIntervalHandler _converse.idle_seconds = 0; // Usually initialized by registerIntervalHandler
_converse.disco_entities.get(_converse.domain).features['urn:xmpp:csi:0'] = true; // Mock that the server supports CSI _converse.disco_entities.get(_converse.domain).features['urn:xmpp:csi:0'] = true; // Mock that the server supports CSI
_converse.csi_waiting_time = 3; // The relevant config option _converse.api.settings.set('csi_waiting_time', 3);
while (i <= _converse.csi_waiting_time) { while (i <= _converse.api.settings.get("csi_waiting_time")) {
expect(_converse.sendCSI).not.toHaveBeenCalled(); expect(_converse.sendCSI).not.toHaveBeenCalled();
_converse.onEverySecond(); _converse.onEverySecond();
i++; i++;
...@@ -52,9 +52,6 @@ ...@@ -52,9 +52,6 @@
_converse.onUserActivity(); _converse.onUserActivity();
expect(_converse.sendCSI).toHaveBeenCalledWith('active'); expect(_converse.sendCSI).toHaveBeenCalledWith('active');
expect(sent_stanza.toLocaleString()).toBe('<active xmlns="urn:xmpp:csi:0"/>'); expect(sent_stanza.toLocaleString()).toBe('<active xmlns="urn:xmpp:csi:0"/>');
// Reset values
_converse.csi_waiting_time = 0;
_converse.disco_entities.get(_converse.domain).features['urn:xmpp:csi:0'] = false;
done(); done();
})); }));
}); });
...@@ -66,13 +63,11 @@ ...@@ -66,13 +63,11 @@
// Usually initialized by registerIntervalHandler // Usually initialized by registerIntervalHandler
_converse.idle_seconds = 0; _converse.idle_seconds = 0;
_converse.auto_changed_status = false; _converse.auto_changed_status = false;
_converse.api.settings.set('auto_away', 3);
// The relevant config options _converse.api.settings.set('auto_xa', 6);
_converse.auto_away = 3;
_converse.auto_xa = 6;
expect(_converse.api.user.status.get()).toBe('online'); expect(_converse.api.user.status.get()).toBe('online');
while (i <= _converse.auto_away) { while (i <= _converse.api.settings.get("auto_away")) {
_converse.onEverySecond(); i++; _converse.onEverySecond(); i++;
} }
expect(_converse.auto_changed_status).toBe(true); expect(_converse.auto_changed_status).toBe(true);
...@@ -92,7 +87,7 @@ ...@@ -92,7 +87,7 @@
// Check that it also works for the chat feature // Check that it also works for the chat feature
_converse.api.user.status.set('chat') _converse.api.user.status.set('chat')
i = 0; i = 0;
while (i <= _converse.auto_away) { while (i <= _converse.api.settings.get("auto_away")) {
_converse.onEverySecond(); _converse.onEverySecond();
i++; i++;
} }
...@@ -112,7 +107,7 @@ ...@@ -112,7 +107,7 @@
// Check that it doesn't work for 'dnd' // Check that it doesn't work for 'dnd'
_converse.api.user.status.set('dnd'); _converse.api.user.status.set('dnd');
i = 0; i = 0;
while (i <= _converse.auto_away) { while (i <= _converse.api.settings.get("auto_away")) {
_converse.onEverySecond(); _converse.onEverySecond();
i++; i++;
} }
......
...@@ -203,7 +203,7 @@ converse.plugins.add('converse-bookmark-views', { ...@@ -203,7 +203,7 @@ converse.plugins.add('converse-bookmark-views', {
}, },
toHTML () { toHTML () {
const is_hidden = b => !!(_converse.hide_open_bookmarks && _converse.chatboxes.get(b.get('jid'))); const is_hidden = b => !!(_converse.api.settings.get('hide_open_bookmarks') && _converse.chatboxes.get(b.get('jid')));
return tpl_bookmarks_list({ return tpl_bookmarks_list({
'_converse': _converse, '_converse': _converse,
'bookmarks': this.model, 'bookmarks': this.model,
......
...@@ -74,7 +74,7 @@ converse.plugins.add('converse-chatboxviews', { ...@@ -74,7 +74,7 @@ converse.plugins.add('converse-chatboxviews', {
if (el === null) { if (el === null) {
el = document.createElement('div'); el = document.createElement('div');
el.setAttribute('id', 'conversejs'); el.setAttribute('id', 'conversejs');
u.addClass(`theme-${_converse.theme}`, el); u.addClass(`theme-${_converse.api.settings.get('theme')}`, el);
const body = _converse.root.querySelector('body'); const body = _converse.root.querySelector('body');
if (body) { if (body) {
body.appendChild(el); body.appendChild(el);
...@@ -97,9 +97,9 @@ converse.plugins.add('converse-chatboxviews', { ...@@ -97,9 +97,9 @@ converse.plugins.add('converse-chatboxviews', {
bg.innerHTML = tpl_background_logo(); bg.innerHTML = tpl_background_logo();
} }
const body = document.querySelector('body'); const body = document.querySelector('body');
body.classList.add(`converse-${_converse.view_mode}`); body.classList.add(`converse-${_converse.api.settings.get("view_mode")}`);
this.el.classList.add(`converse-${_converse.view_mode}`); this.el.classList.add(`converse-${_converse.api.settings.get("view_mode")}`);
if (_converse.singleton) { if (_converse.api.settings.get("singleton")) {
this.el.classList.add(`converse-singleton`); this.el.classList.add(`converse-singleton`);
} }
this.render(); this.render();
......
...@@ -64,7 +64,6 @@ converse.plugins.add('converse-chatview', { ...@@ -64,7 +64,6 @@ converse.plugins.add('converse-chatview', {
'show_send_button': false, 'show_send_button': false,
'show_retraction_warning': true, 'show_retraction_warning': true,
'show_toolbar': true, 'show_toolbar': true,
'time_format': 'HH:mm',
'visible_toolbar_buttons': { 'visible_toolbar_buttons': {
'call': false, 'call': false,
'clear': true, 'clear': true,
...@@ -270,7 +269,7 @@ converse.plugins.add('converse-chatview', { ...@@ -270,7 +269,7 @@ converse.plugins.add('converse-chatview', {
}, },
renderToolbar () { renderToolbar () {
if (!_converse.show_toolbar) { if (!_converse.api.settings.get('show_toolbar')) {
return this; return this;
} }
const options = Object.assign( const options = Object.assign(
...@@ -295,13 +294,13 @@ converse.plugins.add('converse-chatview', { ...@@ -295,13 +294,13 @@ converse.plugins.add('converse-chatview', {
form_container.innerHTML = tpl_chatbox_message_form( form_container.innerHTML = tpl_chatbox_message_form(
Object.assign(this.model.toJSON(), { Object.assign(this.model.toJSON(), {
'__': __, '__': __,
'message_limit': _converse.message_limit, 'message_limit': _converse.api.settings.get('message_limit'),
'hint_value': this.el.querySelector('.spoiler-hint')?.value, 'hint_value': this.el.querySelector('.spoiler-hint')?.value,
'label_message': this.model.get('composing_spoiler') ? __('Hidden message') : __('Message'), 'label_message': this.model.get('composing_spoiler') ? __('Hidden message') : __('Message'),
'label_spoiler_hint': __('Optional hint'), 'label_spoiler_hint': __('Optional hint'),
'message_value': this.el.querySelector('.chat-textarea')?.value, 'message_value': this.el.querySelector('.chat-textarea')?.value,
'show_send_button': _converse.show_send_button, 'show_send_button': _converse.api.settings.get('show_send_button'),
'show_toolbar': _converse.show_toolbar, 'show_toolbar': _converse.api.settings.get('show_toolbar'),
'unread_msgs': __('You have unread messages') 'unread_msgs': __('You have unread messages')
})); }));
this.el.addEventListener('focusin', ev => this.emitFocused(ev)); this.el.addEventListener('focusin', ev => this.emitFocused(ev));
...@@ -430,9 +429,9 @@ converse.plugins.add('converse-chatview', { ...@@ -430,9 +429,9 @@ converse.plugins.add('converse-chatview', {
'i18n_title': __('See more information about this person'), 'i18n_title': __('See more information about this person'),
'icon_class': 'fa-id-card', 'icon_class': 'fa-id-card',
'name': 'details', 'name': 'details',
'standalone': _converse.view_mode === 'overlayed', 'standalone': _converse.api.settings.get("view_mode") === 'overlayed',
}]; }];
if (!_converse.singleton) { if (!_converse.api.settings.get("singleton")) {
buttons.push({ buttons.push({
'a_class': 'close-chatbox-button', 'a_class': 'close-chatbox-button',
'handler': ev => this.close(ev), 'handler': ev => this.close(ev),
...@@ -440,7 +439,7 @@ converse.plugins.add('converse-chatview', { ...@@ -440,7 +439,7 @@ converse.plugins.add('converse-chatview', {
'i18n_title': __('Close and end this conversation'), 'i18n_title': __('Close and end this conversation'),
'icon_class': 'fa-times', 'icon_class': 'fa-times',
'name': 'close', 'name': 'close',
'standalone': _converse.view_mode === 'overlayed', 'standalone': _converse.api.settings.get("view_mode") === 'overlayed',
}); });
} }
return buttons; return buttons;
...@@ -457,9 +456,9 @@ converse.plugins.add('converse-chatview', { ...@@ -457,9 +456,9 @@ converse.plugins.add('converse-chatview', {
'label_clear': __('Clear all messages'), 'label_clear': __('Clear all messages'),
'label_message_limit': __('Message characters remaining'), 'label_message_limit': __('Message characters remaining'),
'label_toggle_spoiler': label_toggle_spoiler, 'label_toggle_spoiler': label_toggle_spoiler,
'message_limit': _converse.message_limit, 'message_limit': _converse.api.settings.get('message_limit'),
'show_call_button': _converse.visible_toolbar_buttons.call, 'show_call_button': _converse.api.settings.get('visible_toolbar_buttons').call,
'show_spoiler_button': _converse.visible_toolbar_buttons.spoiler, 'show_spoiler_button': _converse.api.settings.get('visible_toolbar_buttons').spoiler,
'tooltip_start_call': __('Start a call') 'tooltip_start_call': __('Start a call')
} }
}, },
...@@ -825,7 +824,7 @@ converse.plugins.add('converse-chatview', { ...@@ -825,7 +824,7 @@ converse.plugins.add('converse-chatview', {
ev.preventDefault(); ev.preventDefault();
const textarea = this.el.querySelector('.chat-textarea'); const textarea = this.el.querySelector('.chat-textarea');
const message_text = textarea.value.trim(); const message_text = textarea.value.trim();
if (_converse.message_limit && message_text.length > _converse.message_limit || if (_converse.api.settings.get('message_limit') && message_text.length > _converse.api.settings.get('message_limit') ||
!message_text.replace(/\s/g, '').length) { !message_text.replace(/\s/g, '').length) {
return; return;
} }
...@@ -863,7 +862,7 @@ converse.plugins.add('converse-chatview', { ...@@ -863,7 +862,7 @@ converse.plugins.add('converse-chatview', {
*/ */
_converse.api.trigger('messageSend', message); _converse.api.trigger('messageSend', message);
} }
if (_converse.view_mode === 'overlayed') { if (_converse.api.settings.get("view_mode") === 'overlayed') {
// XXX: Chrome flexbug workaround. The .chat-content area // XXX: Chrome flexbug workaround. The .chat-content area
// doesn't resize when the textarea is resized to its original size. // doesn't resize when the textarea is resized to its original size.
this.msgs_container.parentElement.style.display = 'none'; this.msgs_container.parentElement.style.display = 'none';
...@@ -871,11 +870,10 @@ converse.plugins.add('converse-chatview', { ...@@ -871,11 +870,10 @@ converse.plugins.add('converse-chatview', {
textarea.removeAttribute('disabled'); textarea.removeAttribute('disabled');
u.removeClass('disabled', textarea); u.removeClass('disabled', textarea);
if (_converse.view_mode === 'overlayed') { if (_converse.api.settings.get("view_mode") === 'overlayed') {
// XXX: Chrome flexbug workaround. // XXX: Chrome flexbug workaround.
this.msgs_container.parentElement.style.display = ''; this.msgs_container.parentElement.style.display = '';
} }
// Suppress events, otherwise superfluous CSN gets set // Suppress events, otherwise superfluous CSN gets set
// immediately after the message, causing rate-limiting issues. // immediately after the message, causing rate-limiting issues.
this.model.setChatState(_converse.ACTIVE, {'silent': true}); this.model.setChatState(_converse.ACTIVE, {'silent': true});
...@@ -883,9 +881,9 @@ converse.plugins.add('converse-chatview', { ...@@ -883,9 +881,9 @@ converse.plugins.add('converse-chatview', {
}, },
updateCharCounter (chars) { updateCharCounter (chars) {
if (_converse.message_limit) { if (_converse.api.settings.get('message_limit')) {
const message_limit = this.el.querySelector('.message-limit'); const message_limit = this.el.querySelector('.message-limit');
const counter = _converse.message_limit - chars.length; const counter = _converse.api.settings.get('message_limit') - chars.length;
message_limit.textContent = counter; message_limit.textContent = counter;
if (counter < 1) { if (counter < 1) {
u.addClass('error', message_limit); u.addClass('error', message_limit);
...@@ -994,7 +992,7 @@ converse.plugins.add('converse-chatview', { ...@@ -994,7 +992,7 @@ converse.plugins.add('converse-chatview', {
"be removed everywhere."); "be removed everywhere.");
const messages = [__('Are you sure you want to retract this message?')]; const messages = [__('Are you sure you want to retract this message?')];
if (_converse.show_retraction_warning) { if (_converse.api.settings.get('show_retraction_warning')) {
messages[1] = retraction_warning; messages[1] = retraction_warning;
} }
const result = await _converse.api.confirm(__('Confirm'), messages); const result = await _converse.api.confirm(__('Confirm'), messages);
...@@ -1264,7 +1262,7 @@ converse.plugins.add('converse-chatview', { ...@@ -1264,7 +1262,7 @@ converse.plugins.add('converse-chatview', {
}, },
maybeFocus () { maybeFocus () {
_converse.auto_focus && this.focus(); _converse.api.settings.get('auto_focus') && this.focus();
}, },
hide () { hide () {
...@@ -1293,7 +1291,7 @@ converse.plugins.add('converse-chatview', { ...@@ -1293,7 +1291,7 @@ converse.plugins.add('converse-chatview', {
*/ */
_converse.api.trigger('beforeShowingChatView', this); _converse.api.trigger('beforeShowingChatView', this);
if (_converse.animate) { if (_converse.api.settings.get('animate')) {
u.fadeIn(this.el, () => this.afterShown()); u.fadeIn(this.el, () => this.afterShown());
} else { } else {
u.showElement(this.el); u.showElement(this.el);
......
...@@ -70,7 +70,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -70,7 +70,7 @@ converse.plugins.add('converse-controlbox', {
enabled (_converse) { enabled (_converse) {
return !_converse.singleton; return !_converse.api.settings.get("singleton");
}, },
...@@ -119,7 +119,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -119,7 +119,7 @@ converse.plugins.add('converse-controlbox', {
'bookmarked': false, 'bookmarked': false,
'box_id': 'controlbox', 'box_id': 'controlbox',
'chat_state': undefined, 'chat_state': undefined,
'closed': !_converse.show_controlbox_by_default, 'closed': !_converse.api.settings.get('show_controlbox_by_default'),
'num_unread': 0, 'num_unread': 0,
'time_opened': this.get('time_opened') || (new Date()).getTime(), 'time_opened': this.get('time_opened') || (new Date()).getTime(),
'type': _converse.CONTROLBOX_TYPE, 'type': _converse.CONTROLBOX_TYPE,
...@@ -137,7 +137,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -137,7 +137,7 @@ converse.plugins.add('converse-controlbox', {
validate (attrs) { validate (attrs) {
if (attrs.type === _converse.CONTROLBOX_TYPE) { if (attrs.type === _converse.CONTROLBOX_TYPE) {
if (_converse.view_mode === 'embedded' && _converse.singleton) { if (_converse.api.settings.get("view_mode") === 'embedded' && _converse.api.settings.get("singleton")) {
return 'Controlbox not relevant in embedded view mode'; return 'Controlbox not relevant in embedded view mode';
} }
return; return;
...@@ -197,7 +197,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -197,7 +197,7 @@ converse.plugins.add('converse-controlbox', {
render () { render () {
if (this.model.get('connected')) { if (this.model.get('connected')) {
if (this.model.get('closed') === undefined) { if (this.model.get('closed') === undefined) {
this.model.set('closed', !_converse.show_controlbox_by_default); this.model.set('closed', !_converse.api.settings.get('show_controlbox_by_default'));
} }
} }
this.el.innerHTML = tpl_controlbox(Object.assign(this.model.toJSON())); this.el.innerHTML = tpl_controlbox(Object.assign(this.model.toJSON()));
...@@ -225,7 +225,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -225,7 +225,7 @@ converse.plugins.add('converse-controlbox', {
createBrandHeadingHTML () { createBrandHeadingHTML () {
return tpl_brand_heading({ return tpl_brand_heading({
'sticky_controlbox': _converse.sticky_controlbox 'sticky_controlbox': _converse.api.settings.get('sticky_controlbox')
}); });
}, },
...@@ -285,10 +285,10 @@ converse.plugins.add('converse-controlbox', { ...@@ -285,10 +285,10 @@ converse.plugins.add('converse-controlbox', {
if (ev && ev.preventDefault) { ev.preventDefault(); } if (ev && ev.preventDefault) { ev.preventDefault(); }
if (ev?.name === 'closeAllChatBoxes' && if (ev?.name === 'closeAllChatBoxes' &&
(_converse.disconnection_cause !== _converse.LOGOUT || (_converse.disconnection_cause !== _converse.LOGOUT ||
_converse.show_controlbox_by_default)) { _converse.api.settings.get('show_controlbox_by_default'))) {
return; return;
} }
if (_converse.sticky_controlbox) { if (_converse.api.settings.get('sticky_controlbox')) {
return; return;
} }
const connection = _converse?.connection || {}; const connection = _converse?.connection || {};
...@@ -315,7 +315,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -315,7 +315,7 @@ converse.plugins.add('converse-controlbox', {
}, },
hide (callback) { hide (callback) {
if (_converse.sticky_controlbox) { if (_converse.api.settings.get('sticky_controlbox')) {
return; return;
} }
u.addClass('hidden', this.el); u.addClass('hidden', this.el);
...@@ -387,12 +387,12 @@ converse.plugins.add('converse-controlbox', { ...@@ -387,12 +387,12 @@ converse.plugins.add('converse-controlbox', {
'LOGIN': _converse.LOGIN, 'LOGIN': _converse.LOGIN,
'PREBIND': _converse.PREBIND, 'PREBIND': _converse.PREBIND,
'auto_login': _converse.auto_login, 'auto_login': _converse.auto_login,
'authentication': _converse.authentication, 'authentication': _converse.api.settings.get("authentication"),
'connection_status': connection_status, 'connection_status': connection_status,
'conn_feedback_class': feedback_class, 'conn_feedback_class': feedback_class,
'conn_feedback_subject': pretty_status, 'conn_feedback_subject': pretty_status,
'conn_feedback_message': _converse.connfeedback.get('message'), 'conn_feedback_message': _converse.connfeedback.get('message'),
'placeholder_username': (_converse.locked_domain || _converse.default_domain) && 'placeholder_username': (_converse.api.settings.get('locked_domain') || _converse.api.settings.get('default_domain')) &&
__('Username') || __('user@domain'), __('Username') || __('user@domain'),
'show_trust_checkbox': _converse.trusted !== 'on' && _converse.trusted !== 'off' 'show_trust_checkbox': _converse.trusted !== 'on' && _converse.trusted !== 'off'
}) })
...@@ -402,8 +402,8 @@ converse.plugins.add('converse-controlbox', { ...@@ -402,8 +402,8 @@ converse.plugins.add('converse-controlbox', {
initPopovers () { initPopovers () {
Array.from(this.el.querySelectorAll('[data-title]')).forEach(el => { Array.from(this.el.querySelectorAll('[data-title]')).forEach(el => {
new bootstrap.Popover(el, { new bootstrap.Popover(el, {
'trigger': _converse.view_mode === 'mobile' && 'click' || 'hover', 'trigger': _converse.api.settings.get("view_mode") === 'mobile' && 'click' || 'hover',
'dismissible': _converse.view_mode === 'mobile' && true || false, 'dismissible': _converse.api.settings.get("view_mode") === 'mobile' && true || false,
'container': this.el.parentElement.parentElement.parentElement 'container': this.el.parentElement.parentElement.parentElement
}) })
}); });
...@@ -413,8 +413,8 @@ converse.plugins.add('converse-controlbox', { ...@@ -413,8 +413,8 @@ converse.plugins.add('converse-controlbox', {
const form = this.el.querySelector('form'); const form = this.el.querySelector('form');
const jid_element = form.querySelector('input[name=jid]'); const jid_element = form.querySelector('input[name=jid]');
if (jid_element.value && if (jid_element.value &&
!_converse.locked_domain && !_converse.api.settings.get('locked_domain') &&
!_converse.default_domain && !_converse.api.settings.get('default_domain') &&
!u.isValidJID(jid_element.value)) { !u.isValidJID(jid_element.value)) {
jid_element.setCustomValidity(__('Please enter a valid XMPP address')); jid_element.setCustomValidity(__('Please enter a valid XMPP address'));
return false; return false;
...@@ -427,7 +427,7 @@ converse.plugins.add('converse-controlbox', { ...@@ -427,7 +427,7 @@ converse.plugins.add('converse-controlbox', {
/* Authenticate the user based on a form submission event. /* Authenticate the user based on a form submission event.
*/ */
if (ev && ev.preventDefault) { ev.preventDefault(); } if (ev && ev.preventDefault) { ev.preventDefault(); }
if (_converse.authentication === _converse.ANONYMOUS) { if (_converse.api.settings.get("authentication") === _converse.ANONYMOUS) {
return this.connect(_converse.jid, null); return this.connect(_converse.jid, null);
} }
if (!this.validate()) { return; } if (!this.validate()) { return; }
...@@ -447,14 +447,14 @@ converse.plugins.add('converse-controlbox', { ...@@ -447,14 +447,14 @@ converse.plugins.add('converse-controlbox', {
} }
let jid = form_data.get('jid'); let jid = form_data.get('jid');
if (_converse.locked_domain) { if (_converse.api.settings.get('locked_domain')) {
const last_part = '@' + _converse.locked_domain; const last_part = '@' + _converse.api.settings.get('locked_domain');
if (jid.endsWith(last_part)) { if (jid.endsWith(last_part)) {
jid = jid.substr(0, jid.length - last_part.length); jid = jid.substr(0, jid.length - last_part.length);
} }
jid = Strophe.escapeNode(jid) + last_part; jid = Strophe.escapeNode(jid) + last_part;
} else if (_converse.default_domain && !jid.includes('@')) { } else if (_converse.api.settings.get('default_domain') && !jid.includes('@')) {
jid = jid + '@' + _converse.default_domain; jid = jid + '@' + _converse.api.settings.get('default_domain');
} }
this.connect(jid, form_data.get('password')); this.connect(jid, form_data.get('password'));
}, },
......
...@@ -36,7 +36,7 @@ converse.plugins.add('converse-dragresize', { ...@@ -36,7 +36,7 @@ converse.plugins.add('converse-dragresize', {
dependencies: ["converse-chatview", "converse-headlines-view", "converse-muc-views"], dependencies: ["converse-chatview", "converse-headlines-view", "converse-muc-views"],
enabled (_converse) { enabled (_converse) {
return _converse.view_mode == 'overlayed'; return _converse.api.settings.get("view_mode") == 'overlayed';
}, },
overrides: { overrides: {
...@@ -252,7 +252,9 @@ converse.plugins.add('converse-dragresize', { ...@@ -252,7 +252,9 @@ converse.plugins.add('converse-dragresize', {
}, },
onStartVerticalResize (ev, trigger=true) { onStartVerticalResize (ev, trigger=true) {
if (!_converse.allow_dragresize) { return true; } if (!_converse.api.settings.get('allow_dragresize')) {
return true;
}
// Record element attributes for mouseMove(). // Record element attributes for mouseMove().
const flyout = this.el.querySelector('.box-flyout'), const flyout = this.el.querySelector('.box-flyout'),
style = window.getComputedStyle(flyout); style = window.getComputedStyle(flyout);
...@@ -273,7 +275,9 @@ converse.plugins.add('converse-dragresize', { ...@@ -273,7 +275,9 @@ converse.plugins.add('converse-dragresize', {
}, },
onStartHorizontalResize (ev, trigger=true) { onStartHorizontalResize (ev, trigger=true) {
if (!_converse.allow_dragresize) { return true; } if (!_converse.api.settings.get('allow_dragresize')) {
return true;
}
const flyout = this.el.querySelector('.box-flyout'), const flyout = this.el.querySelector('.box-flyout'),
style = window.getComputedStyle(flyout); style = window.getComputedStyle(flyout);
this.width = parseInt(style.width.replace(/px$/, ''), 10); this.width = parseInt(style.width.replace(/px$/, ''), 10);
...@@ -328,14 +332,18 @@ converse.plugins.add('converse-dragresize', { ...@@ -328,14 +332,18 @@ converse.plugins.add('converse-dragresize', {
function onMouseMove (ev) { function onMouseMove (ev) {
if (!_converse.resizing || !_converse.allow_dragresize) { return true; } if (!_converse.resizing || !_converse.api.settings.get('allow_dragresize')) {
return true;
}
ev.preventDefault(); ev.preventDefault();
_converse.resizing.chatbox.resizeChatBox(ev); _converse.resizing.chatbox.resizeChatBox(ev);
} }
function onMouseUp (ev) { function onMouseUp (ev) {
if (!_converse.resizing || !_converse.allow_dragresize) { return true; } if (!_converse.resizing || !_converse.api.settings.get('allow_dragresize')) {
return true;
}
ev.preventDefault(); ev.preventDefault();
const height = u.applyDragResistance( const height = u.applyDragResistance(
_converse.resizing.chatbox.height, _converse.resizing.chatbox.height,
......
...@@ -151,7 +151,7 @@ converse.plugins.add('converse-emoji-views', { ...@@ -151,7 +151,7 @@ converse.plugins.add('converse-emoji-views', {
Object.assign( Object.assign(
this.model.toJSON(), { this.model.toJSON(), {
'_converse': _converse, '_converse': _converse,
'emoji_categories': _converse.emoji_categories, 'emoji_categories': _converse.api.settings.get('emoji_categories'),
'emojis_by_category': _converse.emojis.json, 'emojis_by_category': _converse.emojis.json,
'onSkintonePicked': ev => this.chooseSkinTone(ev), 'onSkintonePicked': ev => this.chooseSkinTone(ev),
'onEmojiPicked': ev => this.insertEmoji(ev), 'onEmojiPicked': ev => this.insertEmoji(ev),
...@@ -418,7 +418,7 @@ converse.plugins.add('converse-emoji-views', { ...@@ -418,7 +418,7 @@ converse.plugins.add('converse-emoji-views', {
_converse.api.listen.on('chatBoxClosed', view => view.emoji_picker_view && view.emoji_picker_view.remove()); _converse.api.listen.on('chatBoxClosed', view => view.emoji_picker_view && view.emoji_picker_view.remove());
_converse.api.listen.on('renderToolbar', view => { _converse.api.listen.on('renderToolbar', view => {
if (_converse.visible_toolbar_buttons.emoji) { if (_converse.api.settings.get('visible_toolbar_buttons').emoji) {
const html = tpl_emoji_button({'tooltip_insert_smiley': __('Insert emojis')}); const html = tpl_emoji_button({'tooltip_insert_smiley': __('Insert emojis')});
view.el.querySelector('.chat-toolbar').insertAdjacentHTML('afterBegin', html); view.el.querySelector('.chat-toolbar').insertAdjacentHTML('afterBegin', html);
} }
......
...@@ -67,7 +67,7 @@ converse.plugins.add('converse-message-view', { ...@@ -67,7 +67,7 @@ converse.plugins.add('converse-message-view', {
_converse.api.settings.update({ _converse.api.settings.update({
'show_images_inline': true, 'show_images_inline': true,
'allow_message_retraction': 'all' 'time_format': 'HH:mm',
}); });
_converse.MessageVersionsModal = BootstrapModal.extend({ _converse.MessageVersionsModal = BootstrapModal.extend({
...@@ -153,7 +153,7 @@ converse.plugins.add('converse-message-view', { ...@@ -153,7 +153,7 @@ converse.plugins.add('converse-message-view', {
}, },
fadeOut () { fadeOut () {
if (_converse.animate) { if (_converse.api.settings.get('animate')) {
setTimeout(() => this.remove(), 600); setTimeout(() => this.remove(), 600);
u.addClass('fade-out', this.el); u.addClass('fade-out', this.el);
} else { } else {
...@@ -207,7 +207,7 @@ converse.plugins.add('converse-message-view', { ...@@ -207,7 +207,7 @@ converse.plugins.add('converse-message-view', {
await _converse.api.trigger('beforeMessageBodyTransformed', this, text, {'Synchronous': true}); await _converse.api.trigger('beforeMessageBodyTransformed', this, text, {'Synchronous': true});
text = this.model.isMeCommand() ? text.substring(4) : text; text = this.model.isMeCommand() ? text.substring(4) : text;
text = xss.filterXSS(text, {'whiteList': {}, 'onTag': onTagFoundDuringXSSFilter}); text = xss.filterXSS(text, {'whiteList': {}, 'onTag': onTagFoundDuringXSSFilter});
text = u.geoUriToHttp(text, _converse.geouri_replacement); text = u.geoUriToHttp(text, _converse.api.settings.get("geouri_replacement"));
text = u.addMentionsMarkup(text, this.model.get('references'), this.model.collection.chatbox); text = u.addMentionsMarkup(text, this.model.get('references'), this.model.collection.chatbox);
text = u.addHyperlinks(text); text = u.addHyperlinks(text);
text = u.renderNewLines(text); text = u.renderNewLines(text);
...@@ -243,7 +243,7 @@ converse.plugins.add('converse-message-view', { ...@@ -243,7 +243,7 @@ converse.plugins.add('converse-message-view', {
'is_me_message': this.model.isMeCommand(), 'is_me_message': this.model.isMeCommand(),
'label_show': __('Show more'), 'label_show': __('Show more'),
'occupant': this.model.occupant, 'occupant': this.model.occupant,
'pretty_time': time.format(_converse.time_format), 'pretty_time': time.format(_converse.api.settings.get('time_format')),
'retraction_text': is_retracted ? this.getRetractionText() : null, 'retraction_text': is_retracted ? this.getRetractionText() : null,
'roles': roles, 'roles': roles,
'time': time.toISOString(), 'time': time.toISOString(),
...@@ -259,7 +259,7 @@ converse.plugins.add('converse-message-view', { ...@@ -259,7 +259,7 @@ converse.plugins.add('converse-message-view', {
const msg_content = msg.querySelector('.chat-msg__text'); const msg_content = msg.querySelector('.chat-msg__text');
if (text && text !== url) { if (text && text !== url) {
msg_content.innerHTML = await this.transformBodyText(text); msg_content.innerHTML = await this.transformBodyText(text);
if (_converse.show_images_inline) { if (_converse.api.settings.get('show_images_inline')) {
u.renderImageURLs(_converse, msg_content).then(() => this.triggerRendered()); u.renderImageURLs(_converse, msg_content).then(() => this.triggerRendered());
} }
} }
......
...@@ -40,7 +40,7 @@ converse.plugins.add('converse-minimize', { ...@@ -40,7 +40,7 @@ converse.plugins.add('converse-minimize', {
], ],
enabled (_converse) { enabled (_converse) {
return _converse.view_mode === 'overlayed'; return _converse.api.settings.get("view_mode") === 'overlayed';
}, },
overrides: { overrides: {
...@@ -81,7 +81,7 @@ converse.plugins.add('converse-minimize', { ...@@ -81,7 +81,7 @@ converse.plugins.add('converse-minimize', {
show () { show () {
const { _converse } = this.__super__; const { _converse } = this.__super__;
if (_converse.view_mode === 'overlayed' && this.model.get('minimized')) { if (_converse.api.settings.get("view_mode") === 'overlayed' && this.model.get('minimized')) {
this.model.minimize(); this.model.minimize();
return this; return this;
} else { } else {
...@@ -121,7 +121,7 @@ converse.plugins.add('converse-minimize', { ...@@ -121,7 +121,7 @@ converse.plugins.add('converse-minimize', {
'i18n_title': __('Minimize this chat'), 'i18n_title': __('Minimize this chat'),
'icon_class': "fa-minus", 'icon_class': "fa-minus",
'name': 'minimize', 'name': 'minimize',
'standalone': _converse.view_mode === 'overlayed' 'standalone': _converse.api.settings.get("view_mode") === 'overlayed'
} }
const names = buttons.map(t => t.name); const names = buttons.map(t => t.name);
const idx = names.indexOf('close'); const idx = names.indexOf('close');
...@@ -149,7 +149,7 @@ converse.plugins.add('converse-minimize', { ...@@ -149,7 +149,7 @@ converse.plugins.add('converse-minimize', {
'i18n_title': __('Minimize this groupchat'), 'i18n_title': __('Minimize this groupchat'),
'icon_class': "fa-minus", 'icon_class': "fa-minus",
'name': 'minimize', 'name': 'minimize',
'standalone': _converse.view_mode === 'overlayed' 'standalone': _converse.api.settings.get("view_mode") === 'overlayed'
} }
const names = buttons.map(t => t.name); const names = buttons.map(t => t.name);
const idx = names.indexOf('signout'); const idx = names.indexOf('signout');
...@@ -314,7 +314,7 @@ converse.plugins.add('converse-minimize', { ...@@ -314,7 +314,7 @@ converse.plugins.add('converse-minimize', {
* @param { _converse.ChatBoxView|_converse.ChatRoomView|_converse.ControlBoxView|_converse.HeadlinesBoxView } [newchat] * @param { _converse.ChatBoxView|_converse.ChatRoomView|_converse.ControlBoxView|_converse.HeadlinesBoxView } [newchat]
*/ */
async trimChats (newchat) { async trimChats (newchat) {
if (_converse.no_trimming || !_converse.api.connection.connected() || _converse.view_mode !== 'overlayed') { if (_converse.api.settings.get('no_trimming') || !_converse.api.connection.connected() || _converse.api.settings.get("view_mode") !== 'overlayed') {
return; return;
} }
const shown_chats = this.getShownChats(); const shown_chats = this.getShownChats();
......
...@@ -1225,7 +1225,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -1225,7 +1225,7 @@ converse.plugins.add('converse-muc-views', {
}); });
} }
if (!_converse.singleton) { if (!_converse.api.settings.get("singleton")) {
buttons.push({ buttons.push({
'i18n_text': __('Leave'), 'i18n_text': __('Leave'),
'i18n_title': __('Leave and close this groupchat'), 'i18n_title': __('Leave and close this groupchat'),
...@@ -1235,7 +1235,7 @@ converse.plugins.add('converse-muc-views', { ...@@ -1235,7 +1235,7 @@ converse.plugins.add('converse-muc-views', {
result && this.close(ev); result && this.close(ev);
}, },
'a_class': 'close-chatbox-button', 'a_class': 'close-chatbox-button',
'standalone': _converse.view_mode === 'overlayed', 'standalone': _converse.api.settings.get("view_mode") === 'overlayed',
'icon_class': 'fa-sign-out-alt', 'icon_class': 'fa-sign-out-alt',
'name': 'signout' 'name': 'signout'
}); });
......
...@@ -30,7 +30,7 @@ converse.plugins.add('converse-notification', { ...@@ -30,7 +30,7 @@ converse.plugins.add('converse-notification', {
chatstate_notification_blacklist: [], chatstate_notification_blacklist: [],
// ^ a list of JIDs to ignore concerning chat state notifications // ^ a list of JIDs to ignore concerning chat state notifications
play_sounds: true, play_sounds: true,
sounds_path: _converse.assets_path+'/sounds/', sounds_path: _converse.api.settings.get("assets_path")+'/sounds/',
notification_icon: 'logo/conversejs-filled.svg', notification_icon: 'logo/conversejs-filled.svg',
notification_delay: 5000 notification_delay: 5000
}); });
...@@ -135,7 +135,7 @@ converse.plugins.add('converse-notification', { ...@@ -135,7 +135,7 @@ converse.plugins.add('converse-notification', {
const full_from_jid = message.getAttribute('from'), const full_from_jid = message.getAttribute('from'),
from_jid = Strophe.getBareJidFromJid(full_from_jid); from_jid = Strophe.getBareJidFromJid(full_from_jid);
if (message.getAttribute('type') === 'headline') { if (message.getAttribute('type') === 'headline') {
if (!from_jid.includes('@') || _converse.allow_non_roster_messaging) { if (!from_jid.includes('@') || _converse.api.settings.get("allow_non_roster_messaging")) {
title = __("Notification from %1$s", from_jid); title = __("Notification from %1$s", from_jid);
} else { } else {
return; return;
...@@ -154,7 +154,7 @@ converse.plugins.add('converse-notification', { ...@@ -154,7 +154,7 @@ converse.plugins.add('converse-notification', {
if (roster_item !== undefined) { if (roster_item !== undefined) {
title = __("%1$s says", roster_item.getDisplayName()); title = __("%1$s says", roster_item.getDisplayName());
} else { } else {
if (_converse.allow_non_roster_messaging) { if (_converse.api.settings.get("allow_non_roster_messaging")) {
title = __("%1$s says", from_jid); title = __("%1$s says", from_jid);
} else { } else {
return; return;
......
...@@ -56,7 +56,7 @@ converse.plugins.add("converse-oauth", { ...@@ -56,7 +56,7 @@ converse.plugins.add("converse-oauth", {
render () { render () {
const { _converse } = this.__super__; const { _converse } = this.__super__;
const result = this.__super__.render.apply(this, arguments); const result = this.__super__.render.apply(this, arguments);
if (_converse.oauth_providers && !_converse.auto_login) { if (_converse.oauth_providers && !_converse.api.settings.get("auto_login")) {
this.insertOAuthProviders(); this.insertOAuthProviders();
} }
return result; return result;
...@@ -79,7 +79,7 @@ converse.plugins.add("converse-oauth", { ...@@ -79,7 +79,7 @@ converse.plugins.add("converse-oauth", {
'sync': function sync () {}, 'sync': function sync () {},
initialize () { initialize () {
_converse.user_settings.oauth_providers.forEach(provider => { _converse.api.settings.get('oauth_providers').forEach(provider => {
const item = new Model(Object.assign(provider, { const item = new Model(Object.assign(provider, {
'login_text': __('Log in with %1$s', provider.name) 'login_text': __('Log in with %1$s', provider.name)
})); }));
......
...@@ -66,7 +66,7 @@ function parseBundle (bundle_el) { ...@@ -66,7 +66,7 @@ function parseBundle (bundle_el) {
converse.plugins.add('converse-omemo', { converse.plugins.add('converse-omemo', {
enabled (_converse) { enabled (_converse) {
return window.libsignal && !_converse.blacklisted_plugins.includes('converse-omemo') && _converse.config.get('trusted'); return window.libsignal && !_converse.api.settings.get("blacklisted_plugins").includes('converse-omemo') && _converse.config.get('trusted');
}, },
dependencies: ["converse-chatview", "converse-pubsub", "converse-profile"], dependencies: ["converse-chatview", "converse-pubsub", "converse-profile"],
...@@ -306,7 +306,7 @@ converse.plugins.add('converse-omemo', { ...@@ -306,7 +306,7 @@ converse.plugins.add('converse-omemo', {
}, },
reportDecryptionError (e) { reportDecryptionError (e) {
if (_converse.loglevel === 'debug') { if (_converse.api.settings.get("loglevel") === 'debug') {
const { __ } = _converse; const { __ } = _converse;
this.createMessage({ this.createMessage({
'message': __("Sorry, could not decrypt a received OMEMO message due to an error.") + ` ${e.name} ${e.message}`, 'message': __("Sorry, could not decrypt a received OMEMO message due to an error.") + ` ${e.name} ${e.message}`,
...@@ -1222,7 +1222,7 @@ converse.plugins.add('converse-omemo', { ...@@ -1222,7 +1222,7 @@ converse.plugins.add('converse-omemo', {
supported = await _converse.contactHasOMEMOSupport(chatbox.get('jid')); supported = await _converse.contactHasOMEMOSupport(chatbox.get('jid'));
} }
chatbox.set('omemo_supported', supported); chatbox.set('omemo_supported', supported);
if (supported && _converse.omemo_default) { if (supported && _converse.api.settings.get('omemo_default')) {
chatbox.set('omemo_active', true); chatbox.set('omemo_active', true);
} }
} }
......
...@@ -97,8 +97,8 @@ converse.plugins.add('converse-push', { ...@@ -97,8 +97,8 @@ converse.plugins.add('converse-push', {
if (push_enabled.includes(domain)) { if (push_enabled.includes(domain)) {
return; return;
} }
const enabled_services = reject(_converse.push_app_servers, 'disable'); const enabled_services = reject(_converse.api.settings.get('push_app_servers'), 'disable');
const disabled_services = filter(_converse.push_app_servers, 'disable'); const disabled_services = filter(_converse.api.settings.get('push_app_servers'), 'disable');
const enabled = enabled_services.map(s => enablePushAppServer(domain, s)); const enabled = enabled_services.map(s => enablePushAppServer(domain, s));
const disabled = disabled_services.map(s => disablePushAppServer(domain, s)); const disabled = disabled_services.map(s => disablePushAppServer(domain, s));
try { try {
...@@ -118,7 +118,7 @@ converse.plugins.add('converse-push', { ...@@ -118,7 +118,7 @@ converse.plugins.add('converse-push', {
enablePush(Strophe.getDomainFromJid(model.get('jid'))); enablePush(Strophe.getDomainFromJid(model.get('jid')));
} }
} }
if (_converse.enable_muc_push) { if (_converse.api.settings.get('enable_muc_push')) {
_converse.api.listen.on('chatBoxesInitialized', () => _converse.chatboxes.on('add', onChatBoxAdded)); _converse.api.listen.on('chatBoxesInitialized', () => _converse.chatboxes.on('add', onChatBoxAdded));
} }
} }
......
...@@ -95,7 +95,7 @@ converse.plugins.add('converse-register', { ...@@ -95,7 +95,7 @@ converse.plugins.add('converse-register', {
}, },
renderRegistrationPanel () { renderRegistrationPanel () {
if (_converse.allow_registration) { if (_converse.api.settings.get('allow_registration')) {
this.registerpanel = new _converse.RegisterPanel({ this.registerpanel = new _converse.RegisterPanel({
'model': this.model 'model': this.model
}); });
...@@ -145,15 +145,15 @@ converse.plugins.add('converse-register', { ...@@ -145,15 +145,15 @@ converse.plugins.add('converse-register', {
this.model.set('registration_form_rendered', false); this.model.set('registration_form_rendered', false);
this.el.innerHTML = tpl_register_panel({ this.el.innerHTML = tpl_register_panel({
'__': __, '__': __,
'default_domain': _converse.registration_domain, 'default_domain': _converse.api.settings.get('registration_domain'),
'label_register': __('Fetch registration form'), 'label_register': __('Fetch registration form'),
'help_providers': __('Tip: A list of public XMPP providers is available'), 'help_providers': __('Tip: A list of public XMPP providers is available'),
'help_providers_link': __('here'), 'help_providers_link': __('here'),
'href_providers': _converse.providers_link, 'href_providers': _converse.api.settings.get('providers_link'),
'domain_placeholder': _converse.domain_placeholder 'domain_placeholder': _converse.api.settings.get('domain_placeholder')
}); });
if (_converse.registration_domain) { if (_converse.api.settings.get('registration_domain')) {
this.fetchRegistrationForm(_converse.registration_domain); this.fetchRegistrationForm(_converse.api.settings.get('registration_domain'));
} }
return this; return this;
}, },
...@@ -324,7 +324,7 @@ converse.plugins.add('converse-register', { ...@@ -324,7 +324,7 @@ converse.plugins.add('converse-register', {
'beforeend', 'beforeend',
tpl_registration_request({ tpl_registration_request({
'__': _converse.__, '__': _converse.__,
'cancel': _converse.registration_domain, 'cancel': _converse.api.settings.get('registration_domain'),
}) })
); );
}, },
...@@ -451,7 +451,7 @@ converse.plugins.add('converse-register', { ...@@ -451,7 +451,7 @@ converse.plugins.add('converse-register', {
'domain': this.domain, 'domain': this.domain,
'title': this.title, 'title': this.title,
'instructions': this.instructions, 'instructions': this.instructions,
'registration_domain': _converse.registration_domain 'registration_domain': _converse.api.settings.get('registration_domain')
}); });
const buttons = form.querySelector('fieldset.buttons'); const buttons = form.querySelector('fieldset.buttons');
...@@ -522,9 +522,9 @@ converse.plugins.add('converse-register', { ...@@ -522,9 +522,9 @@ converse.plugins.add('converse-register', {
_converse.connection._proto._abortAllRequests(); _converse.connection._proto._abortAllRequests();
_converse.connection.reset(); _converse.connection.reset();
if (this.model.get('registration_form_rendered')) { if (this.model.get('registration_form_rendered')) {
if (_converse.registration_domain && this.model.get('registration_form_rendered')) { if (_converse.api.settings.get('registration_domain') && this.model.get('registration_form_rendered')) {
this.fetchRegistrationForm( this.fetchRegistrationForm(
_converse.registration_domain _converse.api.settings.get('registration_domain')
); );
} }
} else { } else {
......
...@@ -42,7 +42,6 @@ converse.plugins.add('converse-rosterview', { ...@@ -42,7 +42,6 @@ converse.plugins.add('converse-rosterview', {
'allow_contact_removal': true, 'allow_contact_removal': true,
'hide_offline_users': false, 'hide_offline_users': false,
'roster_groups': true, 'roster_groups': true,
'show_toolbar': true,
'xhr_user_search_url': null, 'xhr_user_search_url': null,
}); });
_converse.api.promises.add('rosterViewInitialized'); _converse.api.promises.add('rosterViewInitialized');
...@@ -69,7 +68,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -69,7 +68,7 @@ converse.plugins.add('converse-rosterview', {
}, },
toHTML () { toHTML () {
const label_nickname = _converse.xhr_user_search_url ? __('Contact name') : __('Optional nickname'); const label_nickname = _converse.api.settings.get('xhr_user_search_url') ? __('Contact name') : __('Optional nickname');
return tpl_add_contact_modal(Object.assign(this.model.toJSON(), { return tpl_add_contact_modal(Object.assign(this.model.toJSON(), {
'_converse': _converse, '_converse': _converse,
'label_nickname': label_nickname, 'label_nickname': label_nickname,
...@@ -77,7 +76,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -77,7 +76,7 @@ converse.plugins.add('converse-rosterview', {
}, },
afterRender () { afterRender () {
if (_converse.xhr_user_search_url && isString(_converse.xhr_user_search_url)) { if (_converse.api.settings.get('xhr_user_search_url') && isString(_converse.api.settings.get('xhr_user_search_url'))) {
this.initXHRAutoComplete(); this.initXHRAutoComplete();
} else { } else {
this.initJIDAutoComplete(); this.initJIDAutoComplete();
...@@ -87,7 +86,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -87,7 +86,7 @@ converse.plugins.add('converse-rosterview', {
}, },
initJIDAutoComplete () { initJIDAutoComplete () {
if (!_converse.autocomplete_add_contact) { if (!_converse.api.settings.get('autocomplete_add_contact')) {
return; return;
} }
const el = this.el.querySelector('.suggestion-box__jid').parentElement; const el = this.el.querySelector('.suggestion-box__jid').parentElement;
...@@ -99,7 +98,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -99,7 +98,7 @@ converse.plugins.add('converse-rosterview', {
}, },
initXHRAutoComplete () { initXHRAutoComplete () {
if (!_converse.autocomplete_add_contact) { if (!_converse.api.settings.get('autocomplete_add_contact')) {
return this.initXHRFetch(); return this.initXHRFetch();
} }
const el = this.el.querySelector('.suggestion-box__name').parentElement; const el = this.el.querySelector('.suggestion-box__name').parentElement;
...@@ -120,7 +119,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -120,7 +119,7 @@ converse.plugins.add('converse-rosterview', {
}; };
const input_el = this.el.querySelector('input[name="name"]'); const input_el = this.el.querySelector('input[name="name"]');
input_el.addEventListener('input', debounce(() => { input_el.addEventListener('input', debounce(() => {
xhr.open("GET", `${_converse.xhr_user_search_url}q=${encodeURIComponent(input_el.value)}`, true); xhr.open("GET", `${_converse.api.settings.get('xhr_user_search_url')}q=${encodeURIComponent(input_el.value)}`, true);
xhr.send() xhr.send()
} , 300)); } , 300));
this.name_auto_complete.on('suggestion-box-selectcomplete', ev => { this.name_auto_complete.on('suggestion-box-selectcomplete', ev => {
...@@ -177,9 +176,9 @@ converse.plugins.add('converse-rosterview', { ...@@ -177,9 +176,9 @@ converse.plugins.add('converse-rosterview', {
const data = new FormData(ev.target), const data = new FormData(ev.target),
jid = (data.get('jid') || '').trim(); jid = (data.get('jid') || '').trim();
if (!jid && _converse.xhr_user_search_url && isString(_converse.xhr_user_search_url)) { if (!jid && _converse.api.settings.get('xhr_user_search_url') && isString(_converse.api.settings.get('xhr_user_search_url'))) {
const input_el = this.el.querySelector('input[name="name"]'); const input_el = this.el.querySelector('input[name="name"]');
this.xhr.open("GET", `${_converse.xhr_user_search_url}q=${encodeURIComponent(input_el.value)}`, true); this.xhr.open("GET", `${_converse.api.settings.get('xhr_user_search_url')}q=${encodeURIComponent(input_el.value)}`, true);
this.xhr.send() this.xhr.send()
return; return;
} }
...@@ -358,7 +357,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -358,7 +357,7 @@ converse.plugins.add('converse-rosterview', {
Object.assign(this.model.toJSON(), { Object.assign(this.model.toJSON(), {
display_name, display_name,
'desc_remove': __('Click to remove %1$s as a contact', display_name), 'desc_remove': __('Click to remove %1$s as a contact', display_name),
'allow_chat_pending_contacts': _converse.allow_chat_pending_contacts 'allow_chat_pending_contacts': _converse.api.settings.get('allow_chat_pending_contacts')
}) })
); );
} else if (requesting === true) { } else if (requesting === true) {
...@@ -369,7 +368,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -369,7 +368,7 @@ converse.plugins.add('converse-rosterview', {
display_name, display_name,
'desc_accept': __("Click to accept the contact request from %1$s", display_name), 'desc_accept': __("Click to accept the contact request from %1$s", display_name),
'desc_decline': __("Click to decline the contact request from %1$s", display_name), 'desc_decline': __("Click to decline the contact request from %1$s", display_name),
'allow_chat_pending_contacts': _converse.allow_chat_pending_contacts 'allow_chat_pending_contacts': _converse.api.settings.get('allow_chat_pending_contacts')
}) })
); );
} else if (subscription === 'both' || subscription === 'to' || _converse.rosterview.isSelf(jid)) { } else if (subscription === 'both' || subscription === 'to' || _converse.rosterview.isSelf(jid)) {
...@@ -420,7 +419,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -420,7 +419,7 @@ converse.plugins.add('converse-rosterview', {
'desc_status': STATUSES[show], 'desc_status': STATUSES[show],
'desc_chat': __('Click to chat with %1$s (JID: %2$s)', display_name, item.get('jid')), 'desc_chat': __('Click to chat with %1$s (JID: %2$s)', display_name, item.get('jid')),
'desc_remove': __('Click to remove %1$s as a contact', display_name), 'desc_remove': __('Click to remove %1$s as a contact', display_name),
'allow_contact_removal': _converse.allow_contact_removal, 'allow_contact_removal': _converse.api.settings.get('allow_contact_removal'),
'num_unread': item.get('num_unread') || 0, 'num_unread': item.get('num_unread') || 0,
classes: '' classes: ''
}) })
...@@ -439,7 +438,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -439,7 +438,7 @@ converse.plugins.add('converse-rosterview', {
*/ */
mayBeShown () { mayBeShown () {
const chatStatus = this.model.presence.get('show'); const chatStatus = this.model.presence.get('show');
if (_converse.hide_offline_users && chatStatus === 'offline') { if (_converse.api.settings.get('hide_offline_users') && chatStatus === 'offline') {
// If pending or requesting, show // If pending or requesting, show
if ((this.model.get('ask') === 'subscribe') || if ((this.model.get('ask') === 'subscribe') ||
(this.model.get('subscription') === 'from') || (this.model.get('subscription') === 'from') ||
...@@ -459,7 +458,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -459,7 +458,7 @@ converse.plugins.add('converse-rosterview', {
async removeContact (ev) { async removeContact (ev) {
if (ev && ev.preventDefault) { ev.preventDefault(); } if (ev && ev.preventDefault) { ev.preventDefault(); }
if (!_converse.allow_contact_removal) { return; } if (!_converse.api.settings.get('allow_contact_removal')) { return; }
if (!confirm(__("Are you sure you want to remove this contact?"))) { return; } if (!confirm(__("Are you sure you want to remove this contact?"))) { return; }
try { try {
...@@ -893,7 +892,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -893,7 +892,7 @@ converse.plugins.add('converse-rosterview', {
addExistingContact (contact, options) { addExistingContact (contact, options) {
let groups; let groups;
if (_converse.roster_groups) { if (_converse.api.settings.get('roster_groups')) {
groups = contact.get('groups'); groups = contact.get('groups');
groups = (groups.length === 0) ? [_converse.HEADER_UNGROUPED] : groups; groups = (groups.length === 0) ? [_converse.HEADER_UNGROUPED] : groups;
} else { } else {
...@@ -946,7 +945,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -946,7 +945,7 @@ converse.plugins.add('converse-rosterview', {
_converse.api.listen.on('controlBoxInitialized', (view) => { _converse.api.listen.on('controlBoxInitialized', (view) => {
function insertRoster () { function insertRoster () {
if (!view.model.get('connected') || _converse.authentication === _converse.ANONYMOUS) { if (!view.model.get('connected') || _converse.api.settings.get("authentication") === _converse.ANONYMOUS) {
return; return;
} }
/* Place the rosterview inside the "Contacts" panel. */ /* Place the rosterview inside the "Contacts" panel. */
...@@ -963,7 +962,7 @@ converse.plugins.add('converse-rosterview', { ...@@ -963,7 +962,7 @@ converse.plugins.add('converse-rosterview', {
/* Create an instance of RosterView once the RosterGroups /* Create an instance of RosterView once the RosterGroups
* collection has been created (in @converse/headless/converse-core.js) * collection has been created (in @converse/headless/converse-core.js)
*/ */
if (_converse.authentication === _converse.ANONYMOUS) { if (_converse.api.settings.get("authentication") === _converse.ANONYMOUS) {
return; return;
} }
_converse.rosterview = new _converse.RosterView({ _converse.rosterview = new _converse.RosterView({
......
...@@ -10,7 +10,7 @@ import converse from "@converse/headless/converse-core"; ...@@ -10,7 +10,7 @@ import converse from "@converse/headless/converse-core";
converse.plugins.add('converse-singleton', { converse.plugins.add('converse-singleton', {
enabled (_converse) { enabled (_converse) {
return _converse.singleton; return _converse.api.settings.get("singleton");
}, },
initialize () { initialize () {
......
...@@ -69,7 +69,8 @@ converse.plugins.add('converse-bookmarks', { ...@@ -69,7 +69,8 @@ converse.plugins.add('converse-bookmarks', {
// configuration settings. // configuration settings.
_converse.api.settings.update({ _converse.api.settings.update({
allow_bookmarks: true, allow_bookmarks: true,
allow_public_bookmarks: false allow_public_bookmarks: false,
muc_respect_autojoin: true
}); });
_converse.api.promises.add('bookmarksInitialized'); _converse.api.promises.add('bookmarksInitialized');
...@@ -81,7 +82,7 @@ converse.plugins.add('converse-bookmarks', { ...@@ -81,7 +82,7 @@ converse.plugins.add('converse-bookmarks', {
* @method _converse#getNicknameFromBookmark * @method _converse#getNicknameFromBookmark
*/ */
_converse.getNicknameFromBookmark = function (jid) { _converse.getNicknameFromBookmark = function (jid) {
if (!_converse.bookmarks || !_converse.allow_bookmarks) { if (!_converse.bookmarks || !_converse.api.settings.get('allow_bookmarks')) {
return null; return null;
} }
const bookmark = _converse.bookmarks.findWhere({'jid': jid}); const bookmark = _converse.bookmarks.findWhere({'jid': jid});
...@@ -115,7 +116,7 @@ converse.plugins.add('converse-bookmarks', { ...@@ -115,7 +116,7 @@ converse.plugins.add('converse-bookmarks', {
}, },
async openBookmarkedRoom (bookmark) { async openBookmarkedRoom (bookmark) {
if ( _converse.muc_respect_autojoin && bookmark.get('autojoin')) { if ( _converse.api.settings.get('muc_respect_autojoin') && bookmark.get('autojoin')) {
const groupchat = await _converse.api.rooms.create(bookmark.get('jid'), bookmark.get('nick')); const groupchat = await _converse.api.rooms.create(bookmark.get('jid'), bookmark.get('nick'));
groupchat.maybeShow(); groupchat.maybeShow();
} }
...@@ -271,7 +272,7 @@ converse.plugins.add('converse-bookmarks', { ...@@ -271,7 +272,7 @@ converse.plugins.add('converse-bookmarks', {
} }
const initBookmarks = async function () { const initBookmarks = async function () {
if (!_converse.allow_bookmarks) { if (!_converse.api.settings.get('allow_bookmarks')) {
return; return;
} }
if (await _converse.checkBookmarksSupport()) { if (await _converse.checkBookmarksSupport()) {
......
...@@ -51,11 +51,11 @@ converse.plugins.add('converse-bosh', { ...@@ -51,11 +51,11 @@ converse.plugins.add('converse-bosh', {
_converse.startNewPreboundBOSHSession = function () { _converse.startNewPreboundBOSHSession = function () {
if (!_converse.prebind_url) { if (!_converse.api.settings.get('prebind_url')) {
throw new Error("startNewPreboundBOSHSession: If you use prebind then you MUST supply a prebind_url"); throw new Error("startNewPreboundBOSHSession: If you use prebind then you MUST supply a prebind_url");
} }
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('GET', _converse.prebind_url, true); xhr.open('GET', _converse.api.settings.get('prebind_url'), true);
xhr.setRequestHeader('Accept', 'application/json, text/javascript'); xhr.setRequestHeader('Accept', 'application/json, text/javascript');
xhr.onload = async function () { xhr.onload = async function () {
if (xhr.status >= 200 && xhr.status < 400) { if (xhr.status >= 200 && xhr.status < 400) {
......
...@@ -42,10 +42,11 @@ converse.plugins.add('converse-chat', { ...@@ -42,10 +42,11 @@ converse.plugins.add('converse-chat', {
// Refer to docs/source/configuration.rst for explanations of these // Refer to docs/source/configuration.rst for explanations of these
// configuration settings. // configuration settings.
_converse.api.settings.update({ _converse.api.settings.update({
'allow_message_corrections': 'all',
'allow_message_retraction': 'all',
'auto_join_private_chats': [], 'auto_join_private_chats': [],
'clear_messages_on_reconnection': false, 'clear_messages_on_reconnection': false,
'filter_by_resource': false, 'filter_by_resource': false,
'allow_message_corrections': 'all',
'send_chat_state_notifications': true 'send_chat_state_notifications': true
}); });
...@@ -150,7 +151,7 @@ converse.plugins.add('converse-chat', { ...@@ -150,7 +151,7 @@ converse.plugins.add('converse-chat', {
*/ */
mayBeRetracted () { mayBeRetracted () {
const is_own_message = this.get('sender') === 'me'; const is_own_message = this.get('sender') === 'me';
return is_own_message && ['all', 'own'].includes(_converse.allow_message_retraction); return is_own_message && ['all', 'own'].includes(_converse.api.settings.get('allow_message_retraction'));
}, },
safeDestroy () { safeDestroy () {
...@@ -305,7 +306,7 @@ converse.plugins.add('converse-chat', { ...@@ -305,7 +306,7 @@ converse.plugins.add('converse-chat', {
return { return {
'bookmarked': false, 'bookmarked': false,
'chat_state': undefined, 'chat_state': undefined,
'hidden': ['mobile', 'fullscreen'].includes(_converse.view_mode), 'hidden': ['mobile', 'fullscreen'].includes(_converse.api.settings.get("view_mode")),
'message_type': 'chat', 'message_type': 'chat',
'nickname': undefined, 'nickname': undefined,
'num_unread': 0, 'num_unread': 0,
...@@ -452,7 +453,7 @@ converse.plugins.add('converse-chat', { ...@@ -452,7 +453,7 @@ converse.plugins.add('converse-chat', {
} catch (e) { } catch (e) {
log.error(e); log.error(e);
} finally { } finally {
if (_converse.clear_messages_on_reconnection) { if (_converse.api.settings.get('clear_messages_on_reconnection')) {
await this.clearMessages(); await this.clearMessages();
} }
} }
...@@ -469,7 +470,7 @@ converse.plugins.add('converse-chat', { ...@@ -469,7 +470,7 @@ converse.plugins.add('converse-chat', {
}, },
async onReconnection () { async onReconnection () {
if (_converse.clear_messages_on_reconnection) { if (_converse.api.settings.get('clear_messages_on_reconnection')) {
await this.clearMessages(); await this.clearMessages();
} }
this.announceReconnection(); this.announceReconnection();
...@@ -480,8 +481,8 @@ converse.plugins.add('converse-chat', { ...@@ -480,8 +481,8 @@ converse.plugins.add('converse-chat', {
return 'Ignored ChatBox without JID'; return 'Ignored ChatBox without JID';
} }
const room_jids = _converse.auto_join_rooms.map(s => isObject(s) ? s.jid : s); const room_jids = _converse.auto_join_rooms.map(s => isObject(s) ? s.jid : s);
const auto_join = _converse.auto_join_private_chats.concat(room_jids); const auto_join = _converse.api.settings.get('auto_join_private_chats').concat(room_jids);
if (_converse.singleton && !auto_join.includes(attrs.jid) && !_converse.auto_join_on_invite) { if (_converse.api.settings.get("singleton") && !auto_join.includes(attrs.jid) && !_converse.auto_join_on_invite) {
const msg = `${attrs.jid} is not allowed because singleton is true and it's not being auto_joined`; const msg = `${attrs.jid} is not allowed because singleton is true and it's not being auto_joined`;
log.warn(msg); log.warn(msg);
return msg; return msg;
...@@ -935,7 +936,7 @@ converse.plugins.add('converse-chat', { ...@@ -935,7 +936,7 @@ converse.plugins.add('converse-chat', {
/** /**
* Responsible for setting the editable attribute of messages. * Responsible for setting the editable attribute of messages.
* If _converse.allow_message_corrections is "last", then only the last * If _converse.api.settings.get('allow_message_corrections') is "last", then only the last
* message sent from me will be editable. If set to "all" all messages * message sent from me will be editable. If set to "all" all messages
* will be editable. Otherwise no messages will be editable. * will be editable. Otherwise no messages will be editable.
* @method _converse.ChatBox#setEditable * @method _converse.ChatBox#setEditable
...@@ -950,9 +951,9 @@ converse.plugins.add('converse-chat', { ...@@ -950,9 +951,9 @@ converse.plugins.add('converse-chat', {
if (u.isEmptyMessage(attrs) || attrs.sender !== 'me') { if (u.isEmptyMessage(attrs) || attrs.sender !== 'me') {
return; return;
} }
if (_converse.allow_message_corrections === 'all') { if (_converse.api.settings.get('allow_message_corrections') === 'all') {
attrs.editable = !(attrs.file || attrs.retracted || 'oob_url' in attrs); attrs.editable = !(attrs.file || attrs.retracted || 'oob_url' in attrs);
} else if ((_converse.allow_message_corrections === 'last') && (send_time > this.get('time_sent'))) { } else if ((_converse.api.settings.get('allow_message_corrections') === 'last') && (send_time > this.get('time_sent'))) {
this.set({'time_sent': send_time}); this.set({'time_sent': send_time});
const msg = this.messages.findWhere({'editable': true}); const msg = this.messages.findWhere({'editable': true});
if (msg) { if (msg) {
...@@ -1014,8 +1015,8 @@ converse.plugins.add('converse-chat', { ...@@ -1014,8 +1015,8 @@ converse.plugins.add('converse-chat', {
* @method _converse.ChatBox#sendChatState * @method _converse.ChatBox#sendChatState
*/ */
sendChatState () { sendChatState () {
if (_converse.send_chat_state_notifications && this.get('chat_state')) { if (_converse.api.settings.get('send_chat_state_notifications') && this.get('chat_state')) {
const allowed = _converse.send_chat_state_notifications; const allowed = _converse.api.settings.get('send_chat_state_notifications');
if (Array.isArray(allowed) && !allowed.includes(this.get('chat_state'))) { if (Array.isArray(allowed) && !allowed.includes(this.get('chat_state'))) {
return; return;
} }
...@@ -1183,7 +1184,7 @@ converse.plugins.add('converse-chat', { ...@@ -1183,7 +1184,7 @@ converse.plugins.add('converse-chat', {
let to_jid = stanza.getAttribute('to'); let to_jid = stanza.getAttribute('to');
const to_resource = Strophe.getResourceFromJid(to_jid); const to_resource = Strophe.getResourceFromJid(to_jid);
if (_converse.filter_by_resource && (to_resource && to_resource !== _converse.resource)) { if (_converse.api.settings.get('filter_by_resource') && (to_resource && to_resource !== _converse.resource)) {
return log.info(`handleMessageStanza: Ignoring incoming message intended for a different resource: ${to_jid}`); return log.info(`handleMessageStanza: Ignoring incoming message intended for a different resource: ${to_jid}`);
} else if (utils.isHeadlineMessage(_converse, stanza)) { } else if (utils.isHeadlineMessage(_converse, stanza)) {
// XXX: Prosody sends headline messages with the // XXX: Prosody sends headline messages with the
...@@ -1229,7 +1230,7 @@ converse.plugins.add('converse-chat', { ...@@ -1229,7 +1230,7 @@ converse.plugins.add('converse-chat', {
} }
const contact_jid = is_me ? Strophe.getBareJidFromJid(to_jid) : from_bare_jid; const contact_jid = is_me ? Strophe.getBareJidFromJid(to_jid) : from_bare_jid;
const contact = await _converse.api.contacts.get(contact_jid); const contact = await _converse.api.contacts.get(contact_jid);
if (contact === undefined && !_converse.allow_non_roster_messaging) { if (contact === undefined && !_converse.api.settings.get("allow_non_roster_messaging")) {
log.error(`Blocking messaging with a JID not in our roster because allow_non_roster_messaging is false.`); log.error(`Blocking messaging with a JID not in our roster because allow_non_roster_messaging is false.`);
return log.error(stanza); return log.error(stanza);
} }
...@@ -1286,7 +1287,7 @@ converse.plugins.add('converse-chat', { ...@@ -1286,7 +1287,7 @@ converse.plugins.add('converse-chat', {
function autoJoinChats () { function autoJoinChats () {
// Automatically join private chats, based on the // Automatically join private chats, based on the
// "auto_join_private_chats" configuration setting. // "auto_join_private_chats" configuration setting.
_converse.auto_join_private_chats.forEach(jid => { _converse.api.settings.get('auto_join_private_chats').forEach(jid => {
if (_converse.chatboxes.where({'jid': jid}).length) { if (_converse.chatboxes.where({'jid': jid}).length) {
return; return;
} }
......
This diff is collapsed.
...@@ -251,7 +251,7 @@ converse.plugins.add('converse-disco', { ...@@ -251,7 +251,7 @@ converse.plugins.add('converse-disco', {
_converse.api.disco.own.features.add(Strophe.NS.CHATSTATES); _converse.api.disco.own.features.add(Strophe.NS.CHATSTATES);
_converse.api.disco.own.features.add(Strophe.NS.DISCO_INFO); _converse.api.disco.own.features.add(Strophe.NS.DISCO_INFO);
_converse.api.disco.own.features.add(Strophe.NS.ROSTERX); // Limited support _converse.api.disco.own.features.add(Strophe.NS.ROSTERX); // Limited support
if (_converse.message_carbons) { if (_converse.api.settings.get("message_carbons")) {
_converse.api.disco.own.features.add(Strophe.NS.CARBONS); _converse.api.disco.own.features.add(Strophe.NS.CARBONS);
} }
/** /**
......
...@@ -99,7 +99,7 @@ converse.plugins.add('converse-emoji', { ...@@ -99,7 +99,7 @@ converse.plugins.add('converse-emoji', {
_converse.emojis = {}; _converse.emojis = {};
_converse.api.promises.add('emojisInitialized', false); _converse.api.promises.add('emojisInitialized', false);
twemoji.default.base = _converse.emoji_image_path; twemoji.default.base = _converse.api.settings.get('emoji_image_path');
/** /**
...@@ -162,7 +162,7 @@ converse.plugins.add('converse-emoji', { ...@@ -162,7 +162,7 @@ converse.plugins.add('converse-emoji', {
} }
}; };
const transform = u.shortnamesToEmojis; const transform = u.shortnamesToEmojis;
return _converse.use_system_emojis ? transform : text => twemoji.default.parse(transform(text), how); return _converse.api.settings.get('use_system_emojis') ? transform : text => twemoji.default.parse(transform(text), how);
}, },
/** /**
......
...@@ -58,7 +58,7 @@ converse.plugins.add('converse-headlines', { ...@@ -58,7 +58,7 @@ converse.plugins.add('converse-headlines', {
defaults () { defaults () {
return { return {
'bookmarked': false, 'bookmarked': false,
'hidden': ['mobile', 'fullscreen'].includes(_converse.view_mode), 'hidden': ['mobile', 'fullscreen'].includes(_converse.api.settings.get("view_mode")),
'message_type': 'headline', 'message_type': 'headline',
'num_unread': 0, 'num_unread': 0,
'time_opened': this.get('time_opened') || (new Date()).getTime(), 'time_opened': this.get('time_opened') || (new Date()).getTime(),
...@@ -85,7 +85,7 @@ converse.plugins.add('converse-headlines', { ...@@ -85,7 +85,7 @@ converse.plugins.add('converse-headlines', {
const from_jid = message.getAttribute('from'); const from_jid = message.getAttribute('from');
if (from_jid.includes('@') && if (from_jid.includes('@') &&
!_converse.roster.get(from_jid) && !_converse.roster.get(from_jid) &&
!_converse.allow_non_roster_messaging) { !_converse.api.settings.get("allow_non_roster_messaging")) {
return; return;
} }
if (message.querySelector('body') === null) { if (message.querySelector('body') === null) {
......
...@@ -92,7 +92,7 @@ converse.plugins.add('converse-mam', { ...@@ -92,7 +92,7 @@ converse.plugins.add('converse-mam', {
const query = Object.assign({ const query = Object.assign({
'groupchat': is_groupchat, 'groupchat': is_groupchat,
'max': _converse.archived_messages_page_size, 'max': _converse.api.settings.get('archived_messages_page_size'),
'with': this.get('jid'), 'with': this.get('jid'),
}, options); }, options);
...@@ -113,9 +113,9 @@ converse.plugins.add('converse-mam', { ...@@ -113,9 +113,9 @@ converse.plugins.add('converse-mam', {
if (page && result.rsm) { if (page && result.rsm) {
if (page === 'forwards') { if (page === 'forwards') {
options = result.rsm.next(_converse.archived_messages_page_size, options.before); options = result.rsm.next(_converse.api.settings.get('archived_messages_page_size'), options.before);
} else if (page === 'backwards') { } else if (page === 'backwards') {
options = result.rsm.previous(_converse.archived_messages_page_size, options.after); options = result.rsm.previous(_converse.api.settings.get('archived_messages_page_size'), options.after);
} }
return this.fetchArchivedMessages(options, page); return this.fetchArchivedMessages(options, page);
} else { } else {
...@@ -150,11 +150,11 @@ converse.plugins.add('converse-mam', { ...@@ -150,11 +150,11 @@ converse.plugins.add('converse-mam', {
*/ */
const preference = sizzle(`prefs[xmlns="${Strophe.NS.MAM}"]`, iq).pop(); const preference = sizzle(`prefs[xmlns="${Strophe.NS.MAM}"]`, iq).pop();
const default_pref = preference.getAttribute('default'); const default_pref = preference.getAttribute('default');
if (default_pref !== _converse.message_archiving) { if (default_pref !== _converse.api.settings.get('message_archiving')) {
const stanza = $iq({'type': 'set'}) const stanza = $iq({'type': 'set'})
.c('prefs', { .c('prefs', {
'xmlns':Strophe.NS.MAM, 'xmlns':Strophe.NS.MAM,
'default':_converse.message_archiving 'default':_converse.api.settings.get('message_archiving')
}); });
Array.from(preference.children).forEach(child => stanza.cnode(child).up()); Array.from(preference.children).forEach(child => stanza.cnode(child).up());
...@@ -162,19 +162,19 @@ converse.plugins.add('converse-mam', { ...@@ -162,19 +162,19 @@ converse.plugins.add('converse-mam', {
// (see example 18: https://xmpp.org/extensions/xep-0313.html#config) // (see example 18: https://xmpp.org/extensions/xep-0313.html#config)
// but Prosody doesn't do this, so we don't rely on it. // but Prosody doesn't do this, so we don't rely on it.
_converse.api.sendIQ(stanza) _converse.api.sendIQ(stanza)
.then(() => feature.save({'preferences': {'default':_converse.message_archiving}})) .then(() => feature.save({'preferences': {'default':_converse.api.settings.get('message_archiving')}}))
.catch(_converse.onMAMError); .catch(_converse.onMAMError);
} else { } else {
feature.save({'preferences': {'default':_converse.message_archiving}}); feature.save({'preferences': {'default':_converse.api.settings.get('message_archiving')}});
} }
}; };
function getMAMPrefsFromFeature (feature) { function getMAMPrefsFromFeature (feature) {
const prefs = feature.get('preferences') || {}; const prefs = feature.get('preferences') || {};
if (feature.get('var') !== Strophe.NS.MAM || _converse.message_archiving === undefined) { if (feature.get('var') !== Strophe.NS.MAM || _converse.api.settings.get('message_archiving') === undefined) {
return; return;
} }
if (prefs['default'] !== _converse.message_archiving) { if (prefs['default'] !== _converse.api.settings.get('message_archiving')) {
_converse.api.sendIQ($iq({'type': 'get'}).c('prefs', {'xmlns': Strophe.NS.MAM})) _converse.api.sendIQ($iq({'type': 'get'}).c('prefs', {'xmlns': Strophe.NS.MAM}))
.then(iq => _converse.onMAMPreferences(iq, feature)) .then(iq => _converse.onMAMPreferences(iq, feature))
.catch(_converse.onMAMError); .catch(_converse.onMAMError);
...@@ -479,7 +479,7 @@ converse.plugins.add('converse-mam', { ...@@ -479,7 +479,7 @@ converse.plugins.add('converse-mam', {
}, Strophe.NS.MAM); }, Strophe.NS.MAM);
let error; let error;
const iq_result = await _converse.api.sendIQ(stanza, _converse.message_archiving_timeout, false) const iq_result = await _converse.api.sendIQ(stanza, _converse.api.settings.get('message_archiving_timeout'), false)
if (iq_result === null) { if (iq_result === null) {
const err_msg = "Timeout while trying to fetch archived messages."; const err_msg = "Timeout while trying to fetch archived messages.";
log.error(err_msg); log.error(err_msg);
......
...@@ -124,7 +124,7 @@ converse.plugins.add('converse-muc', { ...@@ -124,7 +124,7 @@ converse.plugins.add('converse-muc', {
}); });
_converse.api.promises.add(['roomsAutoJoined']); _converse.api.promises.add(['roomsAutoJoined']);
if (_converse.locked_muc_domain && !isString(_converse.muc_domain)) { if (_converse.api.settings.get('locked_muc_domain') && !isString(_converse.api.settings.get('muc_domain'))) {
throw new Error("Config Error: it makes no sense to set locked_muc_domain "+ throw new Error("Config Error: it makes no sense to set locked_muc_domain "+
"to true when muc_domain is not set"); "to true when muc_domain is not set");
} }
...@@ -207,7 +207,7 @@ converse.plugins.add('converse-muc', { ...@@ -207,7 +207,7 @@ converse.plugins.add('converse-muc', {
const nick = _converse.xmppstatus.getNickname(); const nick = _converse.xmppstatus.getNickname();
if (nick) { if (nick) {
return nick; return nick;
} else if (_converse.muc_nickname_from_jid) { } else if (_converse.api.settings.get('muc_nickname_from_jid')) {
return Strophe.unescapeNode(Strophe.getNodeFromJid(_converse.bare_jid)); return Strophe.unescapeNode(Strophe.getNodeFromJid(_converse.bare_jid));
} }
} }
...@@ -259,7 +259,7 @@ converse.plugins.add('converse-muc', { ...@@ -259,7 +259,7 @@ converse.plugins.add('converse-muc', {
* @returns { Boolean } * @returns { Boolean }
*/ */
mayBeModerated () { mayBeModerated () {
return ['all', 'moderator'].includes(_converse.allow_message_retraction) && return ['all', 'moderator'].includes(_converse.api.settings.get('allow_message_retraction')) &&
this.collection.chatbox.canModerateMessages(); this.collection.chatbox.canModerateMessages();
}, },
...@@ -351,7 +351,7 @@ converse.plugins.add('converse-muc', { ...@@ -351,7 +351,7 @@ converse.plugins.add('converse-muc', {
'num_unread_general': 0, 'num_unread_general': 0,
'bookmarked': false, 'bookmarked': false,
'chat_state': undefined, 'chat_state': undefined,
'hidden': ['mobile', 'fullscreen'].includes(_converse.view_mode), 'hidden': ['mobile', 'fullscreen'].includes(_converse.api.settings.get("view_mode")),
'message_type': 'groupchat', 'message_type': 'groupchat',
'name': '', 'name': '',
'num_unread': 0, 'num_unread': 0,
...@@ -427,7 +427,7 @@ converse.plugins.add('converse-muc', { ...@@ -427,7 +427,7 @@ converse.plugins.add('converse-muc', {
nick = await this.getAndPersistNickname(nick); nick = await this.getAndPersistNickname(nick);
if (!nick) { if (!nick) {
u.safeSave(this.session, {'connection_status': converse.ROOMSTATUS.NICKNAME_REQUIRED}); u.safeSave(this.session, {'connection_status': converse.ROOMSTATUS.NICKNAME_REQUIRED});
if (_converse.muc_show_logs_before_join) { if (_converse.api.settings.get('muc_show_logs_before_join')) {
await this.fetchMessages(); await this.fetchMessages();
} }
return this; return this;
...@@ -436,7 +436,7 @@ converse.plugins.add('converse-muc', { ...@@ -436,7 +436,7 @@ converse.plugins.add('converse-muc', {
'from': _converse.connection.jid, 'from': _converse.connection.jid,
'to': this.getRoomJIDAndNick() 'to': this.getRoomJIDAndNick()
}).c("x", {'xmlns': Strophe.NS.MUC}) }).c("x", {'xmlns': Strophe.NS.MUC})
.c("history", {'maxstanzas': this.features.get('mam_enabled') ? 0 : _converse.muc_history_max_stanzas}).up(); .c("history", {'maxstanzas': this.features.get('mam_enabled') ? 0 : _converse.api.settings.get('muc_history_max_stanzas')}).up();
if (password) { if (password) {
stanza.cnode(Strophe.xmlElement("password", [], password)); stanza.cnode(Strophe.xmlElement("password", [], password));
...@@ -493,7 +493,7 @@ converse.plugins.add('converse-muc', { ...@@ -493,7 +493,7 @@ converse.plugins.add('converse-muc', {
*/ */
_converse.api.trigger('enteredNewRoom', this); _converse.api.trigger('enteredNewRoom', this);
if (_converse.auto_register_muc_nickname && if (_converse.api.settings.get('auto_register_muc_nickname') &&
await _converse.api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid'))) { await _converse.api.disco.supports(Strophe.NS.MUC_REGISTER, this.get('jid'))) {
this.registerNickname() this.registerNickname()
} }
...@@ -618,7 +618,7 @@ converse.plugins.add('converse-muc', { ...@@ -618,7 +618,7 @@ converse.plugins.add('converse-muc', {
}, },
invitesAllowed () { invitesAllowed () {
return _converse.allow_muc_invitations && return _converse.api.settings.get('allow_muc_invitations') &&
(this.features.get('open') || (this.features.get('open') ||
this.getOwnAffiliation() === "owner" this.getOwnAffiliation() === "owner"
); );
...@@ -628,7 +628,7 @@ converse.plugins.add('converse-muc', { ...@@ -628,7 +628,7 @@ converse.plugins.add('converse-muc', {
const name = this.get('name'); const name = this.get('name');
if (name) { if (name) {
return name; return name;
} else if (_converse.locked_muc_domain === 'hidden') { } else if (_converse.api.settings.get('locked_muc_domain') === 'hidden') {
return Strophe.getNodeFromJid(this.get('jid')); return Strophe.getNodeFromJid(this.get('jid'));
} else { } else {
return this.get('jid'); return this.get('jid');
...@@ -2089,7 +2089,7 @@ converse.plugins.add('converse-muc', { ...@@ -2089,7 +2089,7 @@ converse.plugins.add('converse-muc', {
onNicknameClash (presence) { onNicknameClash (presence) {
if (_converse.muc_nickname_from_jid) { if (_converse.api.settings.get('muc_nickname_from_jid')) {
const nick = presence.getAttribute('from').split('/')[1]; const nick = presence.getAttribute('from').split('/')[1];
if (nick === _converse.getDefaultMUCNickname()) { if (nick === _converse.getDefaultMUCNickname()) {
this.join(nick + '-2'); this.join(nick + '-2');
...@@ -2216,7 +2216,7 @@ converse.plugins.add('converse-muc', { ...@@ -2216,7 +2216,7 @@ converse.plugins.add('converse-muc', {
if (locked_room) { if (locked_room) {
if (this.get('auto_configure')) { if (this.get('auto_configure')) {
this.autoConfigureChatRoom().then(() => this.refreshDiscoInfo()); this.autoConfigureChatRoom().then(() => this.refreshDiscoInfo());
} else if (_converse.muc_instant_rooms) { } else if (_converse.api.settings.get('muc_instant_rooms')) {
// Accept default configuration // Accept default configuration
this.sendConfiguration().then(() => this.refreshDiscoInfo()); this.sendConfiguration().then(() => this.refreshDiscoInfo());
} else { } else {
...@@ -2359,7 +2359,7 @@ converse.plugins.add('converse-muc', { ...@@ -2359,7 +2359,7 @@ converse.plugins.add('converse-muc', {
}, },
getAutoFetchedAffiliationLists () { getAutoFetchedAffiliationLists () {
const affs = _converse.muc_fetch_members; const affs = _converse.api.settings.get('muc_fetch_members');
return Array.isArray(affs) ? affs : (affs ? ['member', 'admin', 'owner'] : []); return Array.isArray(affs) ? affs : (affs ? ['member', 'admin', 'owner'] : []);
}, },
...@@ -2426,13 +2426,13 @@ converse.plugins.add('converse-muc', { ...@@ -2426,13 +2426,13 @@ converse.plugins.add('converse-muc', {
_converse.RoomsPanelModel = Model.extend({ _converse.RoomsPanelModel = Model.extend({
defaults: function () { defaults: function () {
return { return {
'muc_domain': _converse.muc_domain, 'muc_domain': _converse.api.settings.get('muc_domain'),
'nick': _converse.getDefaultMUCNickname() 'nick': _converse.getDefaultMUCNickname()
} }
}, },
setDomain (jid) { setDomain (jid) {
if (!_converse.locked_muc_domain) { if (!_converse.api.settings.get('locked_muc_domain')) {
this.save('muc_domain', Strophe.getDomainFromJid(jid)); this.save('muc_domain', Strophe.getDomainFromJid(jid));
} }
} }
...@@ -2453,7 +2453,7 @@ converse.plugins.add('converse-muc', { ...@@ -2453,7 +2453,7 @@ converse.plugins.add('converse-muc', {
reason = x_el.getAttribute('reason'); reason = x_el.getAttribute('reason');
let result; let result;
if (_converse.auto_join_on_invite) { if (_converse.api.settings.get('auto_join_on_invite')) {
result = true; result = true;
} else { } else {
// Invite request might come from someone not your roster list // Invite request might come from someone not your roster list
...@@ -2478,7 +2478,7 @@ converse.plugins.add('converse-muc', { ...@@ -2478,7 +2478,7 @@ converse.plugins.add('converse-muc', {
} }
}; };
if (_converse.allow_muc_invitations) { if (_converse.api.settings.get('allow_muc_invitations')) {
const registerDirectInvitationHandler = function () { const registerDirectInvitationHandler = function () {
_converse.connection.addHandler( _converse.connection.addHandler(
(message) => { (message) => {
...@@ -2504,7 +2504,7 @@ converse.plugins.add('converse-muc', { ...@@ -2504,7 +2504,7 @@ converse.plugins.add('converse-muc', {
* settings). * settings).
*/ */
function autoJoinRooms () { function autoJoinRooms () {
_converse.auto_join_rooms.forEach(groupchat => { _converse.api.settings.get('auto_join_rooms').forEach(groupchat => {
if (isString(groupchat)) { if (isString(groupchat)) {
if (_converse.chatboxes.where({'jid': groupchat}).length) { if (_converse.chatboxes.where({'jid': groupchat}).length) {
return; return;
...@@ -2542,10 +2542,10 @@ converse.plugins.add('converse-muc', { ...@@ -2542,10 +2542,10 @@ converse.plugins.add('converse-muc', {
_converse.api.listen.on('windowStateChanged', onWindowStateChanged); _converse.api.listen.on('windowStateChanged', onWindowStateChanged);
_converse.api.listen.on('addClientFeatures', () => { _converse.api.listen.on('addClientFeatures', () => {
if (_converse.allow_muc) { if (_converse.api.settings.get('allow_muc')) {
_converse.api.disco.own.features.add(Strophe.NS.MUC); _converse.api.disco.own.features.add(Strophe.NS.MUC);
} }
if (_converse.allow_muc_invitations) { if (_converse.api.settings.get('allow_muc_invitations')) {
_converse.api.disco.own.features.add('jabber:x:conference'); // Invites _converse.api.disco.own.features.add('jabber:x:conference'); // Invites
} }
}); });
...@@ -2624,7 +2624,7 @@ converse.plugins.add('converse-muc', { ...@@ -2624,7 +2624,7 @@ converse.plugins.add('converse-muc', {
*/ */
create (jids, attrs={}) { create (jids, attrs={}) {
attrs = isString(attrs) ? {'nick': attrs} : (attrs || {}); attrs = isString(attrs) ? {'nick': attrs} : (attrs || {});
if (!attrs.nick && _converse.muc_nickname_from_jid) { if (!attrs.nick && _converse.api.settings.get('muc_nickname_from_jid')) {
attrs.nick = Strophe.getNodeFromJid(_converse.bare_jid); attrs.nick = Strophe.getNodeFromJid(_converse.bare_jid);
} }
if (jids === undefined) { if (jids === undefined) {
......
...@@ -46,7 +46,7 @@ converse.plugins.add('converse-ping', { ...@@ -46,7 +46,7 @@ converse.plugins.add('converse-ping', {
function registerPingHandler () { function registerPingHandler () {
_converse.connection.addHandler(() => { _converse.connection.addHandler(() => {
if (_converse.ping_interval > 0) { if (_converse.api.settings.get('ping_interval') > 0) {
// Handler on each stanza, saves the received date // Handler on each stanza, saves the received date
// in order to ping only when needed. // in order to ping only when needed.
lastStanzaDate = new Date(); lastStanzaDate = new Date();
...@@ -56,12 +56,12 @@ converse.plugins.add('converse-ping', { ...@@ -56,12 +56,12 @@ converse.plugins.add('converse-ping', {
} }
setTimeout(() => { setTimeout(() => {
if (_converse.ping_interval > 0) { if (_converse.api.settings.get('ping_interval') > 0) {
const now = new Date(); const now = new Date();
if (!lastStanzaDate) { if (!lastStanzaDate) {
lastStanzaDate = now; lastStanzaDate = now;
} }
if ((now - lastStanzaDate)/1000 > _converse.ping_interval) { if ((now - lastStanzaDate)/1000 > _converse.api.settings.get('ping_interval')) {
return _converse.api.ping(); return _converse.api.ping();
} }
return true; return true;
......
...@@ -710,13 +710,13 @@ converse.plugins.add('converse-roster', { ...@@ -710,13 +710,13 @@ converse.plugins.add('converse-roster', {
bare_jid = Strophe.getBareJidFromJid(jid), bare_jid = Strophe.getBareJidFromJid(jid),
contact = this.get(bare_jid); contact = this.get(bare_jid);
if (!_converse.allow_contact_requests) { if (!_converse.api.settings.get('allow_contact_requests')) {
_converse.rejectPresenceSubscription( _converse.rejectPresenceSubscription(
jid, jid,
__("This client does not allow presence subscriptions") __("This client does not allow presence subscriptions")
); );
} }
if (_converse.auto_subscribe) { if (_converse.api.settings.get('auto_subscribe')) {
if ((!contact) || (contact.get('subscription') !== 'to')) { if ((!contact) || (contact.get('subscription') !== 'to')) {
this.subscribeBack(bare_jid, presence); this.subscribeBack(bare_jid, presence);
} else { } else {
...@@ -742,8 +742,8 @@ converse.plugins.add('converse-roster', { ...@@ -742,8 +742,8 @@ converse.plugins.add('converse-roster', {
if ((_converse.connection.jid !== jid) && if ((_converse.connection.jid !== jid) &&
(presence_type !== 'unavailable') && (presence_type !== 'unavailable') &&
(_converse.synchronize_availability === true || (_converse.api.settings.get('synchronize_availability') === true ||
_converse.synchronize_availability === resource)) { _converse.api.settings.get('synchronize_availability') === resource)) {
// Another resource has changed its status and // Another resource has changed its status and
// synchronize_availability option set to update, // synchronize_availability option set to update,
// we'll update ours as well. // we'll update ours as well.
......
...@@ -185,7 +185,7 @@ converse.plugins.add('converse-smacks', { ...@@ -185,7 +185,7 @@ converse.plugins.add('converse-smacks', {
} }
async function sendEnableStanza () { async function sendEnableStanza () {
if (!_converse.enable_smacks || _converse.session.get('smacks_enabled')) { if (!_converse.api.settings.get('enable_smacks') || _converse.session.get('smacks_enabled')) {
return; return;
} }
if (await isStreamManagementSupported()) { if (await isStreamManagementSupported()) {
...@@ -202,7 +202,7 @@ converse.plugins.add('converse-smacks', { ...@@ -202,7 +202,7 @@ converse.plugins.add('converse-smacks', {
} }
async function enableStreamManagement () { async function enableStreamManagement () {
if (!_converse.enable_smacks) { if (!_converse.api.settings.get('enable_smacks')) {
return; return;
} }
if (!(await isStreamManagementSupported())) { if (!(await isStreamManagementSupported())) {
...@@ -235,7 +235,7 @@ converse.plugins.add('converse-smacks', { ...@@ -235,7 +235,7 @@ converse.plugins.add('converse-smacks', {
'unacked_stanzas', 'unacked_stanzas',
(_converse.session.get('unacked_stanzas') || []).concat([stanza_string]) (_converse.session.get('unacked_stanzas') || []).concat([stanza_string])
); );
const max_unacked = _converse.smacks_max_unacked_stanzas; const max_unacked = _converse.api.settings.get('smacks_max_unacked_stanzas');
if (max_unacked > 0) { if (max_unacked > 0) {
const num = _converse.session.get('num_stanzas_since_last_ack') + 1; const num = _converse.session.get('num_stanzas_since_last_ack') + 1;
if (num % max_unacked === 0) { if (num % max_unacked === 0) {
......
...@@ -15,9 +15,17 @@ converse.plugins.add('converse-status', { ...@@ -15,9 +15,17 @@ converse.plugins.add('converse-status', {
initialize () { initialize () {
const { _converse } = this; const { _converse } = this;
_converse.api.settings.update({
auto_away: 0, // Seconds after which user status is set to 'away'
auto_xa: 0, // Seconds after which user status is set to 'xa'
csi_waiting_time: 0, // Support for XEP-0352. Seconds before client is considered idle and CSI is sent out.
default_state: 'online',
priority: 0,
});
_converse.XMPPStatus = Model.extend({ _converse.XMPPStatus = Model.extend({
defaults () { defaults () {
return {"status": _converse.default_state} return {"status": _converse.api.settings.get("default_state")}
}, },
initialize () { initialize () {
...@@ -42,7 +50,7 @@ converse.plugins.add('converse-status', { ...@@ -42,7 +50,7 @@ converse.plugins.add('converse-status', {
constructPresence (type, status_message) { constructPresence (type, status_message) {
let presence; let presence;
type = isString(type) ? type : (this.get('status') || _converse.default_state); type = isString(type) ? type : (this.get('status') || _converse.api.settings.get("default_state"));
status_message = isString(status_message) ? status_message : this.get('status_message'); status_message = isString(status_message) ? status_message : this.get('status_message');
// Most of these presence types are actually not explicitly sent, // Most of these presence types are actually not explicitly sent,
// but I add all of them here for reference and future proofing. // but I add all of them here for reference and future proofing.
...@@ -64,7 +72,9 @@ converse.plugins.add('converse-status', { ...@@ -64,7 +72,9 @@ converse.plugins.add('converse-status', {
if (status_message) { if (status_message) {
presence.c('status').t(status_message).up(); presence.c('status').t(status_message).up();
} }
presence.c('priority').t(isNaN(Number(_converse.priority)) ? 0 : _converse.priority).up();
const priority = _converse.api.settings.get("priority");
presence.c('priority').t(isNaN(Number(priority)) ? 0 : priority).up();
if (_converse.idle) { if (_converse.idle) {
const idle_since = new Date(); const idle_since = new Date();
idle_since.setSeconds(idle_since.getSeconds() - _converse.idle_seconds); idle_since.setSeconds(idle_since.getSeconds() - _converse.idle_seconds);
...@@ -113,7 +123,7 @@ converse.plugins.add('converse-status', { ...@@ -113,7 +123,7 @@ converse.plugins.add('converse-status', {
_converse.auto_changed_status = false; _converse.auto_changed_status = false;
// XXX: we should really remember the original state here, and // XXX: we should really remember the original state here, and
// then set it back to that... // then set it back to that...
_converse.xmppstatus.set('status', _converse.default_state); _converse.xmppstatus.set('status', _converse.api.settings.get("default_state"));
} }
}; };
...@@ -128,24 +138,24 @@ converse.plugins.add('converse-status', { ...@@ -128,24 +138,24 @@ converse.plugins.add('converse-status', {
} }
const stat = _converse.xmppstatus.get('status'); const stat = _converse.xmppstatus.get('status');
_converse.idle_seconds++; _converse.idle_seconds++;
if (_converse.csi_waiting_time > 0 && if (_converse.api.settings.get("csi_waiting_time") > 0 &&
_converse.idle_seconds > _converse.csi_waiting_time && _converse.idle_seconds > _converse.api.settings.get("csi_waiting_time") &&
!_converse.inactive) { !_converse.inactive) {
_converse.sendCSI(_converse.INACTIVE); _converse.sendCSI(_converse.INACTIVE);
} }
if (_converse.idle_presence_timeout > 0 && if (_converse.api.settings.get("idle_presence_timeout") > 0 &&
_converse.idle_seconds > _converse.idle_presence_timeout && _converse.idle_seconds > _converse.api.settings.get("idle_presence_timeout") &&
!_converse.idle) { !_converse.idle) {
_converse.idle = true; _converse.idle = true;
_converse.xmppstatus.sendPresence(); _converse.xmppstatus.sendPresence();
} }
if (_converse.auto_away > 0 && if (_converse.api.settings.get("auto_away") > 0 &&
_converse.idle_seconds > _converse.auto_away && _converse.idle_seconds > _converse.api.settings.get("auto_away") &&
stat !== 'away' && stat !== 'xa' && stat !== 'dnd') { stat !== 'away' && stat !== 'xa' && stat !== 'dnd') {
_converse.auto_changed_status = true; _converse.auto_changed_status = true;
_converse.xmppstatus.set('status', 'away'); _converse.xmppstatus.set('status', 'away');
} else if (_converse.auto_xa > 0 && } else if (_converse.api.settings.get("auto_xa") > 0 &&
_converse.idle_seconds > _converse.auto_xa && _converse.idle_seconds > _converse.api.settings.get("auto_xa") &&
stat !== 'xa' && stat !== 'dnd') { stat !== 'xa' && stat !== 'dnd') {
_converse.auto_changed_status = true; _converse.auto_changed_status = true;
_converse.xmppstatus.set('status', 'xa'); _converse.xmppstatus.set('status', 'xa');
...@@ -157,10 +167,10 @@ converse.plugins.add('converse-status', { ...@@ -157,10 +167,10 @@ converse.plugins.add('converse-status', {
* Required for the auto_away, auto_xa and csi_waiting_time features. * Required for the auto_away, auto_xa and csi_waiting_time features.
*/ */
if ( if (
_converse.auto_away < 1 && _converse.api.settings.get("auto_away") < 1 &&
_converse.auto_xa < 1 && _converse.api.settings.get("auto_xa") < 1 &&
_converse.csi_waiting_time < 1 && _converse.api.settings.get("csi_waiting_time") < 1 &&
_converse.idle_presence_timeout < 1 _converse.api.settings.get("idle_presence_timeout") < 1
) { ) {
// Waiting time of less then one second means features aren't used. // Waiting time of less then one second means features aren't used.
return; return;
......
...@@ -94,7 +94,7 @@ export const i18n = { ...@@ -94,7 +94,7 @@ export const i18n = {
*/ */
async fetchTranslations (_converse) { async fetchTranslations (_converse) {
const locale = _converse.locale; const locale = _converse.locale;
if (!isConverseLocale(locale, _converse.locales) || locale === 'en') { if (!isConverseLocale(locale, _converse.api.settings.get("locales")) || locale === 'en') {
return; return;
} }
const { default: data } = await import(/*webpackChunkName: "locales/[request]" */ `../../locale/${locale}/LC_MESSAGES/converse.po`); const { default: data } = await import(/*webpackChunkName: "locales/[request]" */ `../../locale/${locale}/LC_MESSAGES/converse.po`);
......
...@@ -218,10 +218,15 @@ u.isServiceUnavailableError = function (stanza) { ...@@ -218,10 +218,15 @@ u.isServiceUnavailableError = function (stanza) {
return sizzle(`error[type="cancel"] service-unavailable[xmlns="${Strophe.NS.STANZAS}"]`, stanza).length > 0; return sizzle(`error[type="cancel"] service-unavailable[xmlns="${Strophe.NS.STANZAS}"]`, stanza).length > 0;
} }
/**
* Merge the second object into the first one.
* @private
* @method u#stringToNode
* @param { Object } first
* @param { Object } second
*/
u.merge = function merge (first, second) { u.merge = function merge (first, second) {
/* Merge the second object into the first one. for (const k in second) {
*/
for (var k in second) {
if (isObject(first[k])) { if (isObject(first[k])) {
merge(first[k], second[k]); merge(first[k], second[k]);
} else { } else {
...@@ -493,7 +498,7 @@ u.geoUriToHttp = function(text, geouri_replacement) { ...@@ -493,7 +498,7 @@ u.geoUriToHttp = function(text, geouri_replacement) {
u.httpToGeoUri = function(text, _converse) { u.httpToGeoUri = function(text, _converse) {
const replacement = 'geo:$1,$2'; const replacement = 'geo:$1,$2';
return text.replace(_converse.geouri_regex, replacement); return text.replace(_converse.api.settings.get("geouri_regex"), replacement);
}; };
u.getSelectValues = function (select) { u.getSelectValues = function (select) {
......
...@@ -19,7 +19,7 @@ export default (o) => { ...@@ -19,7 +19,7 @@ export default (o) => {
return html` return html`
<div class="chatbox-title ${ o.status ? '' : "chatbox-title--no-desc"}"> <div class="chatbox-title ${ o.status ? '' : "chatbox-title--no-desc"}">
<div class="chatbox-title--row"> <div class="chatbox-title--row">
${ (!o._converse.singleton) ? html`<div class="chatbox-navback"><i class="fa fa-arrow-left"></i></div>` : '' } ${ (!o._converse.api.settings.get("singleton")) ? html`<div class="chatbox-navback"><i class="fa fa-arrow-left"></i></div>` : '' }
${ (o.type !== o._converse.HEADLINES_TYPE) ? avatar(Object.assign({}, o, avatar_data)) : '' } ${ (o.type !== o._converse.HEADLINES_TYPE) ? avatar(Object.assign({}, o, avatar_data)) : '' }
<div class="chatbox-title__text" title="${o.jid}"> <div class="chatbox-title__text" title="${o.jid}">
${ o.url ? html`<a href="${o.url}" target="_blank" rel="noopener" class="user">${o.display_name}</a>` : o.display_name} ${ o.url ? html`<a href="${o.url}" target="_blank" rel="noopener" class="user">${o.display_name}</a>` : o.display_name}
......
...@@ -33,7 +33,7 @@ const emoji_picker_header = (o) => html` ...@@ -33,7 +33,7 @@ const emoji_picker_header = (o) => html`
const emoji_item = (o) => { const emoji_item = (o) => {
let emoji; let emoji;
if (o._converse.use_system_emojis) { if (o._converse.api.settings.get('use_system_emojis')) {
emoji = unsafeHTML(xss.filterXSS(o.transform(o.emoji.sn), {'whitelist': {'img': []}})); emoji = unsafeHTML(xss.filterXSS(o.transform(o.emoji.sn), {'whitelist': {'img': []}}));
} }
return html` return html`
...@@ -53,7 +53,7 @@ const search_results = (o) => html` ...@@ -53,7 +53,7 @@ const search_results = (o) => html`
`; `;
const emojis_for_category = (o) => html` const emojis_for_category = (o) => html`
<a id="emoji-picker-${o.category}" class="emoji-category__heading" data-category="${o.category}">${ __(o._converse.emoji_category_labels[o.category]) }</a> <a id="emoji-picker-${o.category}" class="emoji-category__heading" data-category="${o.category}">${ __(o._converse.api.settings.get('emoji_category_labels')[o.category]) }</a>
<ul class="emoji-picker" data-category="${o.category}"> <ul class="emoji-picker" data-category="${o.category}">
${ Object.values(o.emojis_by_category[o.category]).map(emoji => emoji_item(Object.assign({emoji}, o))) } ${ Object.values(o.emojis_by_category[o.category]).map(emoji => emoji_item(Object.assign({emoji}, o))) }
</ul> </ul>
...@@ -63,7 +63,7 @@ const emojis_for_category = (o) => html` ...@@ -63,7 +63,7 @@ const emojis_for_category = (o) => html`
const skintone_emoji = (o) => { const skintone_emoji = (o) => {
const shortname = ':'+o.skintone+':'; const shortname = ':'+o.skintone+':';
let emoji; let emoji;
if (o._converse.use_system_emojis) { if (o._converse.api.settings.get('use_system_emojis')) {
emoji = unsafeHTML(xss.filterXSS(o.transform(shortname), {'whitelist': {'img': []}})); emoji = unsafeHTML(xss.filterXSS(o.transform(shortname), {'whitelist': {'img': []}}));
} }
return html` return html`
......
...@@ -34,7 +34,7 @@ const password_input = () => html` ...@@ -34,7 +34,7 @@ const password_input = () => html`
</div> </div>
`; `;
const register_link = (o) => html` const register_link = () => html`
<fieldset class="switch-form"> <fieldset class="switch-form">
<p>${i18n_hint_no_account}</p> <p>${i18n_hint_no_account}</p>
<p><a class="register-account toggle-register-login" href="#converse/register">${i18n_create_account}</a></p> <p><a class="register-account toggle-register-login" href="#converse/register">${i18n_create_account}</a></p>
...@@ -44,7 +44,7 @@ const register_link = (o) => html` ...@@ -44,7 +44,7 @@ const register_link = (o) => html`
const show_register_link = (o) => { const show_register_link = (o) => {
const _converse = o._converse; const _converse = o._converse;
return _converse.allow_registration && return _converse.allow_registration &&
!_converse.auto_login && !_converse.api.settings.get("auto_login") &&
_converse.pluggable.plugins['converse-register'].enabled(_converse); _converse.pluggable.plugins['converse-register'].enabled(_converse);
} }
......
...@@ -14,8 +14,8 @@ export default (o) => html` ...@@ -14,8 +14,8 @@ export default (o) => html`
<canvas class="avatar align-self-center" height="40" width="40"></canvas> <canvas class="avatar align-self-center" height="40" width="40"></canvas>
</a> </a>
<span class="username w-100 align-self-center">${o.fullname}</span> <span class="username w-100 align-self-center">${o.fullname}</span>
${o._converse.show_client_info && html`<a class="controlbox-heading__btn show-client-info fa fa-info-circle align-self-center" title="${i18n_details}"></a>`} ${o._converse.api.settings.get('show_client_info') && html`<a class="controlbox-heading__btn show-client-info fa fa-info-circle align-self-center" title="${i18n_details}"></a>`}
${o._converse.allow_logout && html`<a class="controlbox-heading__btn logout fa fa-sign-out-alt align-self-center" title="${i18n_logout}"></a>`} ${o._converse.api.settings.get('allow_logout') && html`<a class="controlbox-heading__btn logout fa fa-sign-out-alt align-self-center" title="${i18n_logout}"></a>`}
</div> </div>
<div class="d-flex xmpp-status"> <div class="d-flex xmpp-status">
<a class="change-status" title="${i18n_change_status}" data-toggle="modal" data-target="#changeStatusModal"> <a class="change-status" title="${i18n_change_status}" data-toggle="modal" data-target="#changeStatusModal">
......
...@@ -94,7 +94,7 @@ function renderAudioURL (_converse, uri) { ...@@ -94,7 +94,7 @@ function renderAudioURL (_converse, uri) {
} }
function renderImageURL (_converse, uri) { function renderImageURL (_converse, uri) {
if (!_converse.show_images_inline) { if (!_converse.api.settings.get('show_images_inline')) {
return u.convertToHyperlink(uri); return u.convertToHyperlink(uri);
} }
const { __ } = _converse; const { __ } = _converse;
...@@ -207,7 +207,7 @@ async function renderImage (img_url, link_url, el, callback) { ...@@ -207,7 +207,7 @@ async function renderImage (img_url, link_url, el, callback) {
* @returns { Promise } * @returns { Promise }
*/ */
u.renderImageURLs = function (_converse, el) { u.renderImageURLs = function (_converse, el) {
if (!_converse.show_images_inline) { if (!_converse.api.settings.get('show_images_inline')) {
return Promise.resolve(); return Promise.resolve();
} }
const list = el.textContent.match(URL_REGEX) || []; const list = el.textContent.match(URL_REGEX) || [];
......
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