Commit f032af91 authored by JC Brand's avatar JC Brand

Initial work on moving certain settings into a model

parent b02c70b4
......@@ -722,7 +722,7 @@
_converse.root.appendChild(el);
}
}
if (_.includes(['mobile', 'fullscreen'], _converse.view_mode)) {
if (_.includes(['mobile', 'fullscreen'], _converse.settings.get('view_mode'))) {
el.classList.add('fullscreen');
}
el.innerHTML = '';
......@@ -735,7 +735,7 @@
initialize () {
this.model.on("add", this.onChatBoxAdded, this);
this.model.on("destroy", this.removeChat, this);
this.el.classList.add(`converse-${_converse.view_mode}`);
this.el.classList.add(`converse-${_converse.settings.get('view_mode')}`);
this.render();
},
......
......@@ -406,8 +406,8 @@
this.render();
_.forEach(this.el.querySelectorAll('[data-title]'), (el) => {
const popover = new bootstrap.Popover(el, {
'trigger': _converse.view_mode === 'mobile' && 'click' || 'hover',
'dismissible': _converse.view_mode === 'mobile' && true || false,
'trigger': _converse.settings.get('view_mode') === 'mobile' && 'click' || 'hover',
'dismissible': _converse.settings.get('view_mode') === 'mobile' && true || false,
'container': _converse.chatboxviews.el
})
});
......@@ -465,9 +465,10 @@
if (!this.validate()) { return; }
const form_data = new FormData(ev.target);
_converse.trusted = form_data.get('trusted');
_converse.storage = form_data.get('trusted') ? 'local' : 'session';
_converse.settings.save({
'trusted': form_data.get('trusted'),
'storage': form_data.get('trusted') ? 'local' : 'session'
});
let jid = form_data.get('jid');
if (_converse.locked_domain) {
jid = Strophe.escapeNode(jid) + '@' + _converse.locked_domain;
......@@ -578,7 +579,7 @@
});
_converse.on('clearSession', () => {
if (_converse.trusted) {
if (_converse.settings.get('trusted')) {
const chatboxes = _.get(_converse, 'chatboxes', null);
if (!_.isNil(chatboxes)) {
const controlbox = chatboxes.get('controlbox');
......
This diff is collapsed.
......@@ -41,7 +41,7 @@
dependencies: ["converse-chatview", "converse-headline", "converse-muc-views"],
enabled (_converse) {
return _converse.view_mode == 'overlayed';
return _converse.settings.get('view_mode') == 'overlayed';
},
overrides: {
......
......@@ -13,7 +13,7 @@
converse.plugins.add('converse-embedded', {
enabled (_converse) {
return _converse.view_mode === 'embedded';
return _converse.settings.get('view_mode') === 'embedded';
},
initialize () {
......
......@@ -21,7 +21,7 @@
converse.plugins.add('converse-fullscreen', {
enabled (_converse) {
return _.includes(['fullscreen', 'embedded'], _converse.view_mode);
return _.includes(['fullscreen', 'embedded'], _converse.settings.get('view_mode'));
},
overrides: {
......
......@@ -129,7 +129,7 @@
/* Handler method for all incoming messages of type "headline". */
const from_jid = message.getAttribute('from');
if (utils.isHeadlineMessage(_converse, message)) {
if (_.includes(from_jid, '@') && !_converse.allow_non_roster_messaging) {
if (_.includes(from_jid, '@') && !_converse.settings.get('allow_non_roster_messaging')) {
return;
}
const chatbox = _converse.chatboxes.create({
......
......@@ -221,7 +221,7 @@
processMessageText () {
var text = this.get('message');
text = u.geoUriToHttp(text, _converse.geouri_replacement);
text = u.geoUriToHttp(text, _converse.ggeouri_replacementeouri_replacement);
},
getExtraMessageClasses () {
......
......@@ -42,7 +42,7 @@
dependencies: ["converse-chatview", "converse-controlbox", "converse-muc", "converse-muc-views", "converse-headline"],
enabled (_converse) {
return _converse.view_mode == 'overlayed';
return _converse.settings.get('view_mode') == 'overlayed';
},
overrides: {
......
......@@ -108,14 +108,14 @@
// Refer to docs/source/configuration.rst for explanations of these
// configuration settings.
_converse.api.settings.update({
allow_muc: true,
allow_muc_invitations: true,
auto_join_on_invite: false,
auto_join_rooms: [],
muc_domain: undefined,
muc_history_max_stanzas: undefined,
muc_instant_rooms: true,
muc_nickname_from_jid: false
'allow_muc': true,
'allow_muc_invitations': true,
'auto_join_on_invite': false,
'auto_join_rooms': [],
'muc_domain': undefined,
'muc_history_max_stanzas': undefined,
'muc_instant_rooms': true,
'muc_nickname_from_jid': false
});
_converse.api.promises.add(['roomsAutoJoined']);
......
......@@ -71,7 +71,7 @@
};
_converse.isMessageToHiddenChat = function (message) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], _converse.view_mode)) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], _converse.settings.get('view_mode'))) {
const jid = Strophe.getBareJidFromJid(message.getAttribute('from'));
const model = _converse.chatboxes.get(jid);
if (!_.isNil(model)) {
......@@ -138,7 +138,7 @@
const full_from_jid = message.getAttribute('from'),
from_jid = Strophe.getBareJidFromJid(full_from_jid);
if (message.getAttribute('type') === 'headline') {
if (!_.includes(from_jid, '@') || _converse.allow_non_roster_messaging) {
if (!_.includes(from_jid, '@') || _converse.get('allow_non_roster_messaging')) {
title = __("Notification from %1$s", from_jid);
} else {
return;
......@@ -159,7 +159,7 @@
if (!_.isUndefined(roster_item)) {
title = __("%1$s says", roster_item.getDisplayName());
} else {
if (_converse.allow_non_roster_messaging) {
if (_converse.get('allow_non_roster_messaging')) {
title = __("%1$s says", from_jid);
} else {
return;
......
......@@ -821,7 +821,7 @@
}
this.filter_view.showOrHide();
return this;
}, _converse.animate ? 100 : 0),
}, _converse.get('animate') ? 100 : 0),
filter (query, type) {
// First we make sure the filter is restored to its
......
......@@ -46,7 +46,7 @@
ChatBoxes: {
chatBoxMayBeShown (chatbox) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.view_mode)) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.settings.get('view_mode'))) {
return !chatbox.get('hidden');
} else {
return this.__super__.chatBoxMayBeShown.apply(this, arguments);
......@@ -55,7 +55,7 @@
createChatBox (jid, attrs) {
/* Make sure new chat boxes are hidden by default. */
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.view_mode)) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.settings.get('view_mode'))) {
attrs = attrs || {};
attrs.hidden = true;
}
......@@ -65,7 +65,7 @@
ChatBoxView: {
shouldShowOnTextMessage () {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.view_mode)) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.settings.get('view_mode'))) {
return false;
} else {
return this.__super__.shouldShowOnTextMessage.apply(this, arguments);
......@@ -77,7 +77,7 @@
* time. So before opening a chat, we make sure all other
* chats are hidden.
*/
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.view_mode)) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.settings.get('view_mode'))) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
this.model.set('hidden', false);
}
......@@ -87,7 +87,7 @@
ChatRoomView: {
show (focus) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.view_mode)) {
if (_.includes(['mobile', 'fullscreen', 'embedded'], this.__super__._converse.settings.get('view_mode'))) {
_.each(this.__super__._converse.chatboxviews.xget(this.model.get('id')), hideChat);
this.model.set('hidden', false);
}
......
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