Commit f1899d09 authored by JC Brand's avatar JC Brand

Looser coupling with converse-vcard

To make it easier to remove it without breaking stuff.
parent 36761f29
...@@ -48641,19 +48641,24 @@ const AvatarMixin = { ...@@ -48641,19 +48641,24 @@ const AvatarMixin = {
return; return;
} }
const image_type = this.model.vcard.get('image_type'), const data = {
image = this.model.vcard.get('image');
canvas_el.outerHTML = templates_avatar_svg__WEBPACK_IMPORTED_MODULE_4___default()({
'classes': canvas_el.getAttribute('class'), 'classes': canvas_el.getAttribute('class'),
'width': canvas_el.width, 'width': canvas_el.width,
'height': canvas_el.height, 'height': canvas_el.height
'image': "data:" + image_type + ";base64," + image };
});
if (this.model.vcard) {
const image_type = this.model.vcard.get('image_type'),
image = this.model.vcard.get('image');
data['image'] = "data:" + image_type + ";base64," + image;
}
canvas_el.outerHTML = templates_avatar_svg__WEBPACK_IMPORTED_MODULE_4___default()(data);
} }
}; };
_converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins.add('converse-chatboxviews', { _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins.add('converse-chatboxviews', {
dependencies: ["converse-chatboxes"], dependencies: ["converse-chatboxes", "converse-vcard"],
overrides: { overrides: {
// Overrides mentioned here will be picked up by converse.js's // Overrides mentioned here will be picked up by converse.js's
// plugin architecture they will replace existing methods on the // plugin architecture they will replace existing methods on the
...@@ -61849,6 +61854,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -61849,6 +61854,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
}, },
setVCard() { setVCard() {
if (!_converse.vcards) {
// VCards aren't supported
return;
}
if (this.get('type') === 'error') { if (this.get('type') === 'error') {
return; return;
} else if (this.get('type') === 'groupchat') { } else if (this.get('type') === 'groupchat') {
...@@ -61870,12 +61880,12 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -61870,12 +61880,12 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
getDisplayName() { getDisplayName() {
if (this.get('type') === 'groupchat') { if (this.get('type') === 'groupchat') {
return this.get('nick'); return this.get('nick');
} else { } else if (this.contact) {
if (this.contact) {
return this.contact.getDisplayName(); return this.contact.getDisplayName();
} } else if (this.vcard) {
return this.vcard.getDisplayName();
return this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('from'); } else {
return this.get('from');
} }
}, },
...@@ -62015,22 +62025,25 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -62015,22 +62025,25 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
// This happens when the controlbox is in browser storage, // This happens when the controlbox is in browser storage,
// but we're in embedded mode. // but we're in embedded mode.
return; return;
} } // XXX: this creates a dependency on converse-roster, which we
this.vcard = _converse.vcards.findWhere({
'jid': jid
}) || _converse.vcards.create({
'jid': jid
}); // XXX: this creates a dependency on converse-roster, which we
// probably shouldn't have here, so we should probably move // probably shouldn't have here, so we should probably move
// ChatBox out of converse-chatboxes // ChatBox out of converse-chatboxes
this.presence = _converse.presences.findWhere({ this.presence = _converse.presences.findWhere({
'jid': jid 'jid': jid
}) || _converse.presences.create({ }) || _converse.presences.create({
'jid': jid 'jid': jid
}); });
if (_converse.vcards) {
this.vcard = _converse.vcards.findWhere({
'jid': jid
}) || _converse.vcards.create({
'jid': jid
});
}
if (this.get('type') === _converse.PRIVATE_CHAT_TYPE) { if (this.get('type') === _converse.PRIVATE_CHAT_TYPE) {
this.setRosterContact(jid); this.setRosterContact(jid);
} }
...@@ -62070,9 +62083,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -62070,9 +62083,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
getDisplayName() { getDisplayName() {
if (this.contact) { if (this.contact) {
return this.contact.getDisplayName(); return this.contact.getDisplayName();
} else if (this.vcard) {
return this.vcard.getDisplayName();
} else {
return this.get('jid');
} }
return this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('jid');
}, },
getUpdatedMessageAttributes(message, stanza) { getUpdatedMessageAttributes(message, stanza) {
...@@ -64254,16 +64269,6 @@ _converse.initialize = async function (settings, callback) { ...@@ -64254,16 +64269,6 @@ _converse.initialize = async function (settings, callback) {
}, },
initialize() { initialize() {
this.vcard = _converse.vcards.findWhere({
'jid': this.get('jid')
});
if (_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isNil(this.vcard)) {
this.vcard = _converse.vcards.create({
'jid': this.get('jid')
});
}
this.on('change:status', item => { this.on('change:status', item => {
const status = this.get('status'); const status = this.get('status');
this.sendPresence(status); this.sendPresence(status);
...@@ -68820,6 +68825,11 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -68820,6 +68825,11 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
}, },
setVCard() { setVCard() {
if (!_converse.vcards) {
// VCards aren't supported
return;
}
const jid = this.get('jid'); const jid = this.get('jid');
this.vcard = _converse.vcards.findWhere({ this.vcard = _converse.vcards.findWhere({
'jid': jid 'jid': jid
...@@ -68873,11 +68883,21 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -68873,11 +68883,21 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
}, },
getDisplayName() { getDisplayName() {
return this.get('nickname') || this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('jid'); if (this.get('nickname')) {
return this.get('nickname');
} else if (this.vcard) {
return this.vcard.getDisplayName();
} else {
return this.get('jid');
}
}, },
getFullname() { getFullname() {
if (this.vcard) {
return this.vcard.get('fullname'); return this.vcard.get('fullname');
} else {
return this.get('jid');
}
}, },
/** /**
...@@ -69828,6 +69848,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-vca ...@@ -69828,6 +69848,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-vca
} else { } else {
return Backbone.Model.prototype.set.apply(this, arguments); return Backbone.Model.prototype.set.apply(this, arguments);
} }
},
getDisplayName() {
return this.get('nickname') || this.get('fullname') || this.get('jid');
} }
}); });
...@@ -69925,6 +69949,18 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-vca ...@@ -69925,6 +69949,18 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-vca
_converse.api.listen.on('sessionInitialized', _converse.initVCardCollection); _converse.api.listen.on('sessionInitialized', _converse.initVCardCollection);
_converse.api.listen.on('statusInitialized', () => {
const vcards = _converse.vcards;
const jid = _converse.xmppstatus.get('jid');
_converse.xmppstatus.vcard = vcards.findWhere({
'jid': jid
}) || vcards.create({
'jid': jid
});
});
_converse.api.listen.on('addClientFeatures', () => { _converse.api.listen.on('addClientFeatures', () => {
_converse.api.disco.own.features.add(Strophe.NS.VCARD); _converse.api.disco.own.features.add(Strophe.NS.VCARD);
}); });
...@@ -94517,7 +94553,7 @@ __p += '\n </span>\n '; ...@@ -94517,7 +94553,7 @@ __p += '\n </span>\n ';
__p += '<div class="chat-msg__body">'; __p += '<div class="chat-msg__body">';
} ; } ;
__p += '\n '; __p += '\n ';
if (o.received) { ; if (o.received && !o.is_me_message) { ;
__p += ' <span class="fa fa-check chat-msg__receipt"></span> '; __p += ' <span class="fa fa-check chat-msg__receipt"></span> ';
} ; } ;
__p += '\n '; __p += '\n ';
...@@ -23,22 +23,24 @@ const AvatarMixin = { ...@@ -23,22 +23,24 @@ const AvatarMixin = {
if (_.isNull(canvas_el)) { if (_.isNull(canvas_el)) {
return; return;
} }
const image_type = this.model.vcard.get('image_type'), const data = {
image = this.model.vcard.get('image');
canvas_el.outerHTML = tpl_avatar({
'classes': canvas_el.getAttribute('class'), 'classes': canvas_el.getAttribute('class'),
'width': canvas_el.width, 'width': canvas_el.width,
'height': canvas_el.height, 'height': canvas_el.height,
'image': "data:" + image_type + ";base64," + image, }
}); if (this.model.vcard) {
const image_type = this.model.vcard.get('image_type'),
image = this.model.vcard.get('image');
data['image'] = "data:" + image_type + ";base64," + image;
}
canvas_el.outerHTML = tpl_avatar(data);
}, },
}; };
converse.plugins.add('converse-chatboxviews', { converse.plugins.add('converse-chatboxviews', {
dependencies: ["converse-chatboxes"], dependencies: ["converse-chatboxes", "converse-vcard"],
overrides: { overrides: {
// Overrides mentioned here will be picked up by converse.js's // Overrides mentioned here will be picked up by converse.js's
......
...@@ -118,6 +118,10 @@ converse.plugins.add('converse-chatboxes', { ...@@ -118,6 +118,10 @@ converse.plugins.add('converse-chatboxes', {
}, },
setVCard () { setVCard () {
if (!_converse.vcards) {
// VCards aren't supported
return;
}
if (this.get('type') === 'error') { if (this.get('type') === 'error') {
return; return;
} else if (this.get('type') === 'groupchat') { } else if (this.get('type') === 'groupchat') {
...@@ -135,11 +139,12 @@ converse.plugins.add('converse-chatboxes', { ...@@ -135,11 +139,12 @@ converse.plugins.add('converse-chatboxes', {
getDisplayName () { getDisplayName () {
if (this.get('type') === 'groupchat') { if (this.get('type') === 'groupchat') {
return this.get('nick'); return this.get('nick');
} else { } else if (this.contact) {
if (this.contact) {
return this.contact.getDisplayName(); return this.contact.getDisplayName();
} } else if (this.vcard) {
return this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('from'); return this.vcard.getDisplayName();
} else {
return this.get('from');
} }
}, },
...@@ -271,12 +276,15 @@ converse.plugins.add('converse-chatboxes', { ...@@ -271,12 +276,15 @@ converse.plugins.add('converse-chatboxes', {
// but we're in embedded mode. // but we're in embedded mode.
return; return;
} }
this.vcard = _converse.vcards.findWhere({'jid': jid}) || _converse.vcards.create({'jid': jid});
// XXX: this creates a dependency on converse-roster, which we // XXX: this creates a dependency on converse-roster, which we
// probably shouldn't have here, so we should probably move // probably shouldn't have here, so we should probably move
// ChatBox out of converse-chatboxes // ChatBox out of converse-chatboxes
this.presence = _converse.presences.findWhere({'jid': jid}) || _converse.presences.create({'jid': jid}); this.presence = _converse.presences.findWhere({'jid': jid}) || _converse.presences.create({'jid': jid});
if (_converse.vcards) {
this.vcard = _converse.vcards.findWhere({'jid': jid}) || _converse.vcards.create({'jid': jid});
}
if (this.get('type') === _converse.PRIVATE_CHAT_TYPE) { if (this.get('type') === _converse.PRIVATE_CHAT_TYPE) {
this.setRosterContact(jid); this.setRosterContact(jid);
} }
...@@ -317,8 +325,11 @@ converse.plugins.add('converse-chatboxes', { ...@@ -317,8 +325,11 @@ converse.plugins.add('converse-chatboxes', {
getDisplayName () { getDisplayName () {
if (this.contact) { if (this.contact) {
return this.contact.getDisplayName(); return this.contact.getDisplayName();
} else if (this.vcard) {
return this.vcard.getDisplayName();
} else {
return this.get('jid');
} }
return this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('jid');
}, },
getUpdatedMessageAttributes (message, stanza) { getUpdatedMessageAttributes (message, stanza) {
......
...@@ -1059,11 +1059,6 @@ _converse.initialize = async function (settings, callback) { ...@@ -1059,11 +1059,6 @@ _converse.initialize = async function (settings, callback) {
}, },
initialize () { initialize () {
this.vcard = _converse.vcards.findWhere({'jid': this.get('jid')});
if (_.isNil(this.vcard)) {
this.vcard = _converse.vcards.create({'jid': this.get('jid')});
}
this.on('change:status', (item) => { this.on('change:status', (item) => {
const status = this.get('status'); const status = this.get('status');
this.sendPresence(status); this.sendPresence(status);
......
...@@ -211,6 +211,10 @@ converse.plugins.add('converse-roster', { ...@@ -211,6 +211,10 @@ converse.plugins.add('converse-roster', {
}, },
setVCard () { setVCard () {
if (!_converse.vcards) {
// VCards aren't supported
return;
}
const jid = this.get('jid'); const jid = this.get('jid');
this.vcard = _converse.vcards.findWhere({'jid': jid}) || _converse.vcards.create({'jid': jid}); this.vcard = _converse.vcards.findWhere({'jid': jid}) || _converse.vcards.create({'jid': jid});
}, },
...@@ -258,11 +262,21 @@ converse.plugins.add('converse-roster', { ...@@ -258,11 +262,21 @@ converse.plugins.add('converse-roster', {
}, },
getDisplayName () { getDisplayName () {
return this.get('nickname') || this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('jid'); if (this.get('nickname')) {
return this.get('nickname');
} else if (this.vcard) {
return this.vcard.getDisplayName();
} else {
return this.get('jid');
}
}, },
getFullname () { getFullname () {
if (this.vcard) {
return this.vcard.get('fullname'); return this.vcard.get('fullname');
} else {
return this.get('jid');
}
}, },
/** /**
......
...@@ -43,6 +43,10 @@ converse.plugins.add('converse-vcard', { ...@@ -43,6 +43,10 @@ converse.plugins.add('converse-vcard', {
} else { } else {
return Backbone.Model.prototype.set.apply(this, arguments); return Backbone.Model.prototype.set.apply(this, arguments);
} }
},
getDisplayName () {
return this.get('nickname') || this.get('fullname') || this.get('jid');
} }
}); });
...@@ -124,6 +128,13 @@ converse.plugins.add('converse-vcard', { ...@@ -124,6 +128,13 @@ converse.plugins.add('converse-vcard', {
_converse.api.listen.on('sessionInitialized', _converse.initVCardCollection); _converse.api.listen.on('sessionInitialized', _converse.initVCardCollection);
_converse.api.listen.on('statusInitialized', () => {
const vcards = _converse.vcards;
const jid = _converse.xmppstatus.get('jid');
_converse.xmppstatus.vcard = vcards.findWhere({'jid': jid}) || vcards.create({'jid': jid});
});
_converse.api.listen.on('addClientFeatures', () => { _converse.api.listen.on('addClientFeatures', () => {
_converse.api.disco.own.features.add(Strophe.NS.VCARD); _converse.api.disco.own.features.add(Strophe.NS.VCARD);
}); });
......
...@@ -40371,6 +40371,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -40371,6 +40371,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
}, },
setVCard() { setVCard() {
if (!_converse.vcards) {
// VCards aren't supported
return;
}
if (this.get('type') === 'error') { if (this.get('type') === 'error') {
return; return;
} else if (this.get('type') === 'groupchat') { } else if (this.get('type') === 'groupchat') {
...@@ -40392,12 +40397,12 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -40392,12 +40397,12 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
getDisplayName() { getDisplayName() {
if (this.get('type') === 'groupchat') { if (this.get('type') === 'groupchat') {
return this.get('nick'); return this.get('nick');
} else { } else if (this.contact) {
if (this.contact) {
return this.contact.getDisplayName(); return this.contact.getDisplayName();
} } else if (this.vcard) {
return this.vcard.getDisplayName();
return this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('from'); } else {
return this.get('from');
} }
}, },
...@@ -40537,22 +40542,25 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -40537,22 +40542,25 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
// This happens when the controlbox is in browser storage, // This happens when the controlbox is in browser storage,
// but we're in embedded mode. // but we're in embedded mode.
return; return;
} } // XXX: this creates a dependency on converse-roster, which we
this.vcard = _converse.vcards.findWhere({
'jid': jid
}) || _converse.vcards.create({
'jid': jid
}); // XXX: this creates a dependency on converse-roster, which we
// probably shouldn't have here, so we should probably move // probably shouldn't have here, so we should probably move
// ChatBox out of converse-chatboxes // ChatBox out of converse-chatboxes
this.presence = _converse.presences.findWhere({ this.presence = _converse.presences.findWhere({
'jid': jid 'jid': jid
}) || _converse.presences.create({ }) || _converse.presences.create({
'jid': jid 'jid': jid
}); });
if (_converse.vcards) {
this.vcard = _converse.vcards.findWhere({
'jid': jid
}) || _converse.vcards.create({
'jid': jid
});
}
if (this.get('type') === _converse.PRIVATE_CHAT_TYPE) { if (this.get('type') === _converse.PRIVATE_CHAT_TYPE) {
this.setRosterContact(jid); this.setRosterContact(jid);
} }
...@@ -40592,9 +40600,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha ...@@ -40592,9 +40600,11 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
getDisplayName() { getDisplayName() {
if (this.contact) { if (this.contact) {
return this.contact.getDisplayName(); return this.contact.getDisplayName();
} else if (this.vcard) {
return this.vcard.getDisplayName();
} else {
return this.get('jid');
} }
return this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('jid');
}, },
getUpdatedMessageAttributes(message, stanza) { getUpdatedMessageAttributes(message, stanza) {
...@@ -42776,16 +42786,6 @@ _converse.initialize = async function (settings, callback) { ...@@ -42776,16 +42786,6 @@ _converse.initialize = async function (settings, callback) {
}, },
initialize() { initialize() {
this.vcard = _converse.vcards.findWhere({
'jid': this.get('jid')
});
if (_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isNil(this.vcard)) {
this.vcard = _converse.vcards.create({
'jid': this.get('jid')
});
}
this.on('change:status', item => { this.on('change:status', item => {
const status = this.get('status'); const status = this.get('status');
this.sendPresence(status); this.sendPresence(status);
...@@ -47342,6 +47342,11 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -47342,6 +47342,11 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
}, },
setVCard() { setVCard() {
if (!_converse.vcards) {
// VCards aren't supported
return;
}
const jid = this.get('jid'); const jid = this.get('jid');
this.vcard = _converse.vcards.findWhere({ this.vcard = _converse.vcards.findWhere({
'jid': jid 'jid': jid
...@@ -47395,11 +47400,21 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins ...@@ -47395,11 +47400,21 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
}, },
getDisplayName() { getDisplayName() {
return this.get('nickname') || this.vcard.get('nickname') || this.vcard.get('fullname') || this.get('jid'); if (this.get('nickname')) {
return this.get('nickname');
} else if (this.vcard) {
return this.vcard.getDisplayName();
} else {
return this.get('jid');
}
}, },
getFullname() { getFullname() {
if (this.vcard) {
return this.vcard.get('fullname'); return this.vcard.get('fullname');
} else {
return this.get('jid');
}
}, },
/** /**
...@@ -48350,6 +48365,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-vca ...@@ -48350,6 +48365,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-vca
} else { } else {
return Backbone.Model.prototype.set.apply(this, arguments); return Backbone.Model.prototype.set.apply(this, arguments);
} }
},
getDisplayName() {
return this.get('nickname') || this.get('fullname') || this.get('jid');
} }
}); });
...@@ -48447,6 +48466,18 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-vca ...@@ -48447,6 +48466,18 @@ _converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins.add('converse-vca
_converse.api.listen.on('sessionInitialized', _converse.initVCardCollection); _converse.api.listen.on('sessionInitialized', _converse.initVCardCollection);
_converse.api.listen.on('statusInitialized', () => {
const vcards = _converse.vcards;
const jid = _converse.xmppstatus.get('jid');
_converse.xmppstatus.vcard = vcards.findWhere({
'jid': jid
}) || vcards.create({
'jid': jid
});
});
_converse.api.listen.on('addClientFeatures', () => { _converse.api.listen.on('addClientFeatures', () => {
_converse.api.disco.own.features.add(Strophe.NS.VCARD); _converse.api.disco.own.features.add(Strophe.NS.VCARD);
}); });
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