Use vcard from the collection for rendering messages
This commit is contained in:
parent
adf34c845c
commit
99915a26f4
@ -85,7 +85,9 @@
|
|||||||
message = '/me is as well';
|
message = '/me is as well';
|
||||||
test_utils.sendMessage(view, message);
|
test_utils.sendMessage(view, message);
|
||||||
expect(view.el.querySelectorAll('.chat-action').length).toBe(2);
|
expect(view.el.querySelectorAll('.chat-action').length).toBe(2);
|
||||||
expect(_.includes($(view.el).find('.chat-msg-author:last').text(), '**Max Mustermann')).toBeTruthy();
|
|
||||||
|
return test_utils.waitUntil(() => $(view.el).find('.chat-msg-author:last').text() === '**Max Mustermann');
|
||||||
|
}).then(function () {
|
||||||
expect($(view.el).find('.chat-msg-text:last').text()).toBe(' is as well');
|
expect($(view.el).find('.chat-msg-text:last').text()).toBe(' is as well');
|
||||||
expect($(view.el).find('.chat-msg:last').hasClass('chat-msg-followup')).toBe(false);
|
expect($(view.el).find('.chat-msg:last').hasClass('chat-msg-followup')).toBe(false);
|
||||||
|
|
||||||
|
107
spec/messages.js
107
spec/messages.js
@ -67,8 +67,11 @@
|
|||||||
var chat_content = chatboxview.el.querySelector('.chat-content');
|
var chat_content = chatboxview.el.querySelector('.chat-content');
|
||||||
expect(chat_content.querySelector('.chat-msg .chat-msg-text').textContent).toEqual(message);
|
expect(chat_content.querySelector('.chat-msg .chat-msg-text').textContent).toEqual(message);
|
||||||
expect(chat_content.querySelector('.chat-msg-time').textContent.match(/^[0-9][0-9]:[0-9][0-9]/)).toBeTruthy();
|
expect(chat_content.querySelector('.chat-msg-time').textContent.match(/^[0-9][0-9]:[0-9][0-9]/)).toBeTruthy();
|
||||||
expect(chat_content.querySelector('span.chat-msg-author').textContent).toBe('Max Frankfurter');
|
return test_utils.waitUntil(() => chatbox.vcard.get('fullname') === mock.cur_names[0])
|
||||||
done();
|
.then(function () {
|
||||||
|
expect(chat_content.querySelector('span.chat-msg-author').textContent).toBe('Max Frankfurter');
|
||||||
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -120,9 +123,7 @@
|
|||||||
test_utils.waitUntil(function () { return vcard_fetched; }, 100)
|
test_utils.waitUntil(function () { return vcard_fetched; }, 100)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
expect(_converse.api.vcard.get).toHaveBeenCalled();
|
expect(_converse.api.vcard.get).toHaveBeenCalled();
|
||||||
return test_utils.waitUntil(function () {
|
return test_utils.waitUntil(() => chatbox.vcard.get('fullname') === mock.cur_names[0])
|
||||||
return chatbox.get('fullname') === mock.cur_names[0];
|
|
||||||
}, 100);
|
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
var author_el = chatboxview.el.querySelector('.chat-msg-author');
|
var author_el = chatboxview.el.querySelector('.chat-msg-author');
|
||||||
expect( _.includes(author_el.textContent, 'Max Frankfurter')).toBeTruthy();
|
expect( _.includes(author_el.textContent, 'Max Frankfurter')).toBeTruthy();
|
||||||
@ -696,8 +697,11 @@
|
|||||||
var chat_content = chatboxview.el.querySelector('.chat-content');
|
var chat_content = chatboxview.el.querySelector('.chat-content');
|
||||||
expect(chat_content.querySelector('.chat-msg .chat-msg-text').textContent).toEqual(msgtext);
|
expect(chat_content.querySelector('.chat-msg .chat-msg-text').textContent).toEqual(msgtext);
|
||||||
expect(chat_content.querySelector('.chat-msg-time').textContent.match(/^[0-9][0-9]:[0-9][0-9]/)).toBeTruthy();
|
expect(chat_content.querySelector('.chat-msg-time').textContent.match(/^[0-9][0-9]:[0-9][0-9]/)).toBeTruthy();
|
||||||
expect(chat_content.querySelector('span.chat-msg-author').textContent).toBe('Candice van der Knijff');
|
return test_utils.waitUntil(() => chatbox.vcard.get('fullname') === 'Candice van der Knijff')
|
||||||
done();
|
.then(function () {
|
||||||
|
expect(chat_content.querySelector('span.chat-msg-author').textContent).toBe('Candice van der Knijff');
|
||||||
|
done();
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it("can be a carbon message that this user sent from a different client, as defined in XEP-0280",
|
it("can be a carbon message that this user sent from a different client, as defined in XEP-0280",
|
||||||
@ -899,56 +903,59 @@
|
|||||||
expect(msg_obj.get('sender')).toEqual('them');
|
expect(msg_obj.get('sender')).toEqual('them');
|
||||||
expect(msg_obj.get('delayed')).toEqual(true);
|
expect(msg_obj.get('delayed')).toEqual(true);
|
||||||
|
|
||||||
var chat_content = chatboxview.el.querySelector('.chat-content');
|
return test_utils.waitUntil(() => chatbox.vcard.get('fullname') === 'Candice van der Knijff')
|
||||||
expect(chat_content.querySelector('.chat-msg .chat-msg-text').textContent).toEqual(message);
|
.then(function () {
|
||||||
expect(chat_content.querySelector('.chat-msg-time').textContent.match(/^[0-9][0-9]:[0-9][0-9]/)).toBeTruthy();
|
var chat_content = chatboxview.el.querySelector('.chat-content');
|
||||||
expect(chat_content.querySelector('span.chat-msg-author').textContent).toBe('Candice van der Knijff');
|
expect(chat_content.querySelector('.chat-msg .chat-msg-text').textContent).toEqual(message);
|
||||||
|
expect(chat_content.querySelector('.chat-msg-time').textContent.match(/^[0-9][0-9]:[0-9][0-9]/)).toBeTruthy();
|
||||||
|
expect(chat_content.querySelector('span.chat-msg-author').textContent).toBe('Candice van der Knijff');
|
||||||
|
|
||||||
var $day = $chat_content.find('.date-separator');
|
var $day = $chat_content.find('.date-separator');
|
||||||
expect($day.length).toEqual(1);
|
expect($day.length).toEqual(1);
|
||||||
expect($day.attr('class')).toEqual('message date-separator');
|
expect($day.attr('class')).toEqual('message date-separator');
|
||||||
expect($day.data('isodate')).toEqual(moment(one_day_ago.startOf('day')).format());
|
expect($day.data('isodate')).toEqual(moment(one_day_ago.startOf('day')).format());
|
||||||
|
|
||||||
var $time = $chat_content.find('time.separator-text');
|
var $time = $chat_content.find('time.separator-text');
|
||||||
expect($time.text()).toEqual(moment(one_day_ago.startOf('day')).format("dddd MMM Do YYYY"));
|
expect($time.text()).toEqual(moment(one_day_ago.startOf('day')).format("dddd MMM Do YYYY"));
|
||||||
|
|
||||||
message = 'This is a current message';
|
message = 'This is a current message';
|
||||||
msg = $msg({
|
msg = $msg({
|
||||||
from: contact_jid,
|
from: contact_jid,
|
||||||
to: _converse.connection.jid,
|
to: _converse.connection.jid,
|
||||||
type: 'chat',
|
type: 'chat',
|
||||||
id: new Date().getTime()
|
id: new Date().getTime()
|
||||||
}).c('body').t(message).up()
|
}).c('body').t(message).up()
|
||||||
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
|
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
|
||||||
_converse.chatboxes.onMessage(msg);
|
_converse.chatboxes.onMessage(msg);
|
||||||
expect(_converse.emit).toHaveBeenCalledWith('message', jasmine.any(Object));
|
expect(_converse.emit).toHaveBeenCalledWith('message', jasmine.any(Object));
|
||||||
// Check that there is a <time> element, with the required
|
// Check that there is a <time> element, with the required
|
||||||
// props.
|
// props.
|
||||||
expect($chat_content[0].querySelectorAll('time').length).toEqual(2); // There are now two time elements
|
expect($chat_content[0].querySelectorAll('time').length).toEqual(2); // There are now two time elements
|
||||||
|
|
||||||
var message_date = new Date();
|
var message_date = new Date();
|
||||||
$day = $chat_content.find('.date-separator:last');
|
$day = $chat_content.find('.date-separator:last');
|
||||||
expect($day.length).toEqual(1);
|
expect($day.length).toEqual(1);
|
||||||
expect($day.attr('class')).toEqual('message date-separator');
|
expect($day.attr('class')).toEqual('message date-separator');
|
||||||
expect($day.data('isodate')).toEqual(moment(message_date).startOf('day').format());
|
expect($day.data('isodate')).toEqual(moment(message_date).startOf('day').format());
|
||||||
|
|
||||||
$time = $chat_content.find('time.separator-text:last');
|
$time = $chat_content.find('time.separator-text:last');
|
||||||
expect($time.text()).toEqual(moment(message_date).startOf('day').format("dddd MMM Do YYYY"));
|
expect($time.text()).toEqual(moment(message_date).startOf('day').format("dddd MMM Do YYYY"));
|
||||||
|
|
||||||
// Normal checks for the 2nd message
|
// Normal checks for the 2nd message
|
||||||
expect(chatbox.messages.length).toEqual(2);
|
expect(chatbox.messages.length).toEqual(2);
|
||||||
msg_obj = chatbox.messages.models[1];
|
msg_obj = chatbox.messages.models[1];
|
||||||
expect(msg_obj.get('message')).toEqual(message);
|
expect(msg_obj.get('message')).toEqual(message);
|
||||||
expect(msg_obj.get('fullname')).toEqual(contact_name);
|
expect(msg_obj.get('fullname')).toEqual(contact_name);
|
||||||
expect(msg_obj.get('sender')).toEqual('them');
|
expect(msg_obj.get('sender')).toEqual('them');
|
||||||
expect(msg_obj.get('delayed')).toEqual(false);
|
expect(msg_obj.get('delayed')).toEqual(false);
|
||||||
msg_txt = $chat_content.find('.chat-msg').last().find('.chat-msg-text').text();
|
msg_txt = $chat_content.find('.chat-msg').last().find('.chat-msg-text').text();
|
||||||
expect(msg_txt).toEqual(message);
|
expect(msg_txt).toEqual(message);
|
||||||
|
|
||||||
expect(chat_content.querySelector('.chat-msg:last-child .chat-msg-text').textContent).toEqual(message);
|
expect(chat_content.querySelector('.chat-msg:last-child .chat-msg-text').textContent).toEqual(message);
|
||||||
expect(chat_content.querySelector('.chat-msg:last-child .chat-msg-time').textContent.match(/^[0-9][0-9]:[0-9][0-9]/)).toBeTruthy();
|
expect(chat_content.querySelector('.chat-msg:last-child .chat-msg-time').textContent.match(/^[0-9][0-9]:[0-9][0-9]/)).toBeTruthy();
|
||||||
expect(chat_content.querySelector('.chat-msg:last-child .chat-msg-author').textContent).toBe('Candice van der Knijff');
|
expect(chat_content.querySelector('.chat-msg:last-child .chat-msg-author').textContent).toBe('Candice van der Knijff');
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -44,14 +44,18 @@
|
|||||||
_converse.chatboxes.onMessage(msg);
|
_converse.chatboxes.onMessage(msg);
|
||||||
|
|
||||||
var view = _converse.chatboxviews.get(sender_jid);
|
var view = _converse.chatboxviews.get(sender_jid);
|
||||||
expect(view.el.querySelector('.chat-msg-author').textContent).toBe('Max Frankfurter');
|
|
||||||
|
|
||||||
var message_content = view.el.querySelector('.chat-msg-text');
|
return test_utils.waitUntil(() => view.model.vcard.get('fullname') === 'Max Frankfurter')
|
||||||
expect(message_content.textContent).toBe(spoiler);
|
.then(function () {
|
||||||
|
expect(view.el.querySelector('.chat-msg-author').textContent).toBe('Max Frankfurter');
|
||||||
|
|
||||||
var spoiler_hint_el = view.el.querySelector('.spoiler-hint');
|
var message_content = view.el.querySelector('.chat-msg-text');
|
||||||
expect(spoiler_hint_el.textContent).toBe(spoiler_hint);
|
expect(message_content.textContent).toBe(spoiler);
|
||||||
done();
|
|
||||||
|
var spoiler_hint_el = view.el.querySelector('.spoiler-hint');
|
||||||
|
expect(spoiler_hint_el.textContent).toBe(spoiler_hint);
|
||||||
|
done();
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it("can be received without a hint",
|
it("can be received without a hint",
|
||||||
@ -80,14 +84,17 @@
|
|||||||
_converse.chatboxes.onMessage(msg);
|
_converse.chatboxes.onMessage(msg);
|
||||||
|
|
||||||
var view = _converse.chatboxviews.get(sender_jid);
|
var view = _converse.chatboxviews.get(sender_jid);
|
||||||
expect(_.includes(view.el.querySelector('.chat-msg-author').textContent, 'Max Frankfurter')).toBeTruthy();
|
return test_utils.waitUntil(() => view.model.vcard.get('fullname') === 'Max Frankfurter')
|
||||||
|
.then(function () {
|
||||||
|
expect(_.includes(view.el.querySelector('.chat-msg-author').textContent, 'Max Frankfurter')).toBeTruthy();
|
||||||
|
|
||||||
var message_content = view.el.querySelector('.chat-msg-text');
|
var message_content = view.el.querySelector('.chat-msg-text');
|
||||||
expect(message_content.textContent).toBe(spoiler);
|
expect(message_content.textContent).toBe(spoiler);
|
||||||
|
|
||||||
var spoiler_hint_el = view.el.querySelector('.spoiler-hint');
|
var spoiler_hint_el = view.el.querySelector('.spoiler-hint');
|
||||||
expect(spoiler_hint_el.textContent).toBe('');
|
expect(spoiler_hint_el.textContent).toBe('');
|
||||||
done();
|
done();
|
||||||
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it("can be sent without a hint",
|
it("can be sent without a hint",
|
||||||
|
@ -111,6 +111,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDisplayName () {
|
||||||
|
if (this.get('type') === 'groupchat') {
|
||||||
|
return this.get('nick');
|
||||||
|
} else {
|
||||||
|
return this.vcard.get('fullname') || this.get('from');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
sendSlotRequestStanza () {
|
sendSlotRequestStanza () {
|
||||||
/* Send out an IQ stanza to request a file upload slot.
|
/* Send out an IQ stanza to request a file upload slot.
|
||||||
*
|
*
|
||||||
@ -294,7 +302,7 @@
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
'fullname': fullname,
|
'fullname': fullname,
|
||||||
'username': _.isEmpty(fullname) ? _converse.bare_jid : fullname,
|
'from': _converse.bare_jid,
|
||||||
'sender': 'me',
|
'sender': 'me',
|
||||||
'time': moment().format(),
|
'time': moment().format(),
|
||||||
'message': text ? u.httpToGeoUri(emojione.shortnameToUnicode(text), _converse) : undefined,
|
'message': text ? u.httpToGeoUri(emojione.shortnameToUnicode(text), _converse) : undefined,
|
||||||
@ -404,7 +412,6 @@
|
|||||||
if (attrs.type === 'groupchat') {
|
if (attrs.type === 'groupchat') {
|
||||||
attrs.from = message.getAttribute('from');
|
attrs.from = message.getAttribute('from');
|
||||||
attrs.nick = Strophe.unescapeNode(Strophe.getResourceFromJid(attrs.from));
|
attrs.nick = Strophe.unescapeNode(Strophe.getResourceFromJid(attrs.from));
|
||||||
attrs.username = attrs.nick;
|
|
||||||
if (attrs.from === this.get('nick')) {
|
if (attrs.from === this.get('nick')) {
|
||||||
attrs.sender = 'me';
|
attrs.sender = 'me';
|
||||||
} else {
|
} else {
|
||||||
@ -415,11 +422,9 @@
|
|||||||
if (attrs.from === _converse.bare_jid) {
|
if (attrs.from === _converse.bare_jid) {
|
||||||
attrs.sender = 'me';
|
attrs.sender = 'me';
|
||||||
attrs.fullname = _converse.xmppstatus.get('fullname');
|
attrs.fullname = _converse.xmppstatus.get('fullname');
|
||||||
attrs.username = attrs.fullname || attrs.from;
|
|
||||||
} else {
|
} else {
|
||||||
attrs.sender = 'them';
|
attrs.sender = 'them';
|
||||||
attrs.fullname = this.get('fullname');
|
attrs.fullname = this.get('fullname');
|
||||||
attrs.username = attrs.fullname || attrs.from;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_.each(sizzle(`x[xmlns="${Strophe.NS.OUTOFBAND}"]`, message), (xform) => {
|
_.each(sizzle(`x[xmlns="${Strophe.NS.OUTOFBAND}"]`, message), (xform) => {
|
||||||
|
@ -578,14 +578,14 @@
|
|||||||
return this.scrollDown();
|
return this.scrollDown();
|
||||||
},
|
},
|
||||||
|
|
||||||
clearChatStateNotification (username, isodate) {
|
clearChatStateNotification (message, isodate) {
|
||||||
if (isodate) {
|
if (isodate) {
|
||||||
_.each(
|
_.each(
|
||||||
sizzle(`.chat-state-notification[data-csn="${username}"][data-isodate="${isodate}"]`, this.content),
|
sizzle(`.chat-state-notification[data-csn="${message.get('from')}"][data-isodate="${isodate}"]`, this.content),
|
||||||
u.removeElement
|
u.removeElement
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
_.each(sizzle(`.chat-state-notification[data-csn="${username}"]`, this.content), u.removeElement);
|
_.each(sizzle(`.chat-state-notification[data-csn="${message.get('from')}"]`, this.content), u.removeElement);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -593,23 +593,24 @@
|
|||||||
/* Support for XEP-0085, Chat State Notifications */
|
/* Support for XEP-0085, Chat State Notifications */
|
||||||
let text;
|
let text;
|
||||||
const from = message.get('from'),
|
const from = message.get('from'),
|
||||||
username = message.get('username');
|
name = message.getDisplayName();
|
||||||
this.clearChatStateNotification(username);
|
|
||||||
|
this.clearChatStateNotification(message);
|
||||||
|
|
||||||
if (message.get('chat_state') === _converse.COMPOSING) {
|
if (message.get('chat_state') === _converse.COMPOSING) {
|
||||||
if (message.get('sender') === 'me') {
|
if (message.get('sender') === 'me') {
|
||||||
text = __('Typing from another device');
|
text = __('Typing from another device');
|
||||||
} else {
|
} else {
|
||||||
text = username +' '+__('is typing');
|
text = name +' '+__('is typing');
|
||||||
}
|
}
|
||||||
} else if (message.get('chat_state') === _converse.PAUSED) {
|
} else if (message.get('chat_state') === _converse.PAUSED) {
|
||||||
if (message.get('sender') === 'me') {
|
if (message.get('sender') === 'me') {
|
||||||
text = __('Stopped typing on the other device');
|
text = __('Stopped typing on the other device');
|
||||||
} else {
|
} else {
|
||||||
text = username +' '+__('has stopped typing');
|
text = name +' '+__('has stopped typing');
|
||||||
}
|
}
|
||||||
} else if (message.get('chat_state') === _converse.GONE) {
|
} else if (message.get('chat_state') === _converse.GONE) {
|
||||||
text = username +' '+__('has gone away');
|
text = name +' '+__('has gone away');
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -617,7 +618,6 @@
|
|||||||
this.content.insertAdjacentHTML(
|
this.content.insertAdjacentHTML(
|
||||||
'beforeend',
|
'beforeend',
|
||||||
tpl_csn({
|
tpl_csn({
|
||||||
'username': username,
|
|
||||||
'message': text,
|
'message': text,
|
||||||
'from': from,
|
'from': from,
|
||||||
'isodate': isodate
|
'isodate': isodate
|
||||||
@ -625,7 +625,7 @@
|
|||||||
this.scrollDown();
|
this.scrollDown();
|
||||||
|
|
||||||
this.clear_status_timeout = window.setTimeout(
|
this.clear_status_timeout = window.setTimeout(
|
||||||
this.clearChatStateNotification.bind(this, username, isodate),
|
this.clearChatStateNotification.bind(this, message, isodate),
|
||||||
30000
|
30000
|
||||||
);
|
);
|
||||||
return message;
|
return message;
|
||||||
@ -713,7 +713,7 @@
|
|||||||
const view = new _converse.MessageView({'model': message});
|
const view = new _converse.MessageView({'model': message});
|
||||||
this.insertMessage(view);
|
this.insertMessage(view);
|
||||||
this.insertDayIndicator(view.el);
|
this.insertDayIndicator(view.el);
|
||||||
this.clearChatStateNotification(message.get('username'));
|
this.clearChatStateNotification(message);
|
||||||
this.setScrollPosition(view.el);
|
this.setScrollPosition(view.el);
|
||||||
|
|
||||||
if (u.isNewMessage(message)) {
|
if (u.isNewMessage(message)) {
|
||||||
|
@ -70,17 +70,7 @@
|
|||||||
_converse.MessageView = _converse.ViewWithAvatar.extend({
|
_converse.MessageView = _converse.ViewWithAvatar.extend({
|
||||||
|
|
||||||
initialize () {
|
initialize () {
|
||||||
this.chatbox = this.model.collection.chatbox;
|
this.model.vcard.on('change', this.render, this);
|
||||||
this.chatbox.on('change:fullname', (chatbox) => {
|
|
||||||
if (chatbox.get('type') !== 'chatroom') {
|
|
||||||
this.model.save({
|
|
||||||
'fullname': chatbox.get('fullname'),
|
|
||||||
'username': chatbox.get('fullname')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.model.vcard.on('change:image', this.renderAvatar, this);
|
|
||||||
this.model.on('change:fullname', this.render, this);
|
|
||||||
this.model.on('change:progress', this.renderFileUploadProgresBar, this);
|
this.model.on('change:progress', this.renderFileUploadProgresBar, this);
|
||||||
this.model.on('change:type', this.render, this);
|
this.model.on('change:type', this.render, this);
|
||||||
this.model.on('change:upload', this.render, this);
|
this.model.on('change:upload', this.render, this);
|
||||||
@ -101,20 +91,14 @@
|
|||||||
template = this.model.get('is_spoiler') ? tpl_spoiler_message : tpl_message;
|
template = this.model.get('is_spoiler') ? tpl_spoiler_message : tpl_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
let username;
|
|
||||||
if (this.chatbox.get('type') === 'chatroom') {
|
|
||||||
username = this.model.get('nick');
|
|
||||||
} else {
|
|
||||||
username = this.model.get('fullname') || this.model.get('from');
|
|
||||||
}
|
|
||||||
|
|
||||||
const moment_time = moment(this.model.get('time'));
|
const moment_time = moment(this.model.get('time'));
|
||||||
const msg = u.stringToElement(template(
|
const msg = u.stringToElement(template(
|
||||||
_.extend(this.model.toJSON(), {
|
_.extend(this.model.toJSON(), {
|
||||||
'pretty_time': moment_time.format(_converse.time_format),
|
'pretty_time': moment_time.format(_converse.time_format),
|
||||||
'time': moment_time.format(),
|
'time': moment_time.format(),
|
||||||
'extra_classes': this.getExtraMessageClasses(),
|
'extra_classes': this.getExtraMessageClasses(),
|
||||||
'label_show': __('Show more')
|
'label_show': __('Show more'),
|
||||||
|
'username': this.model.getDisplayName()
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -167,21 +151,12 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderFileUploadProgresBar () {
|
renderFileUploadProgresBar () {
|
||||||
let image, image_type;
|
|
||||||
if (this.model.get('sender') === 'me') {
|
|
||||||
image_type = _converse.xmppstatus.get('image_type');
|
|
||||||
image = _converse.xmppstatus.get('image');
|
|
||||||
} else {
|
|
||||||
image_type = this.chatbox.get('image_type');
|
|
||||||
image = this.chatbox.get('image');
|
|
||||||
}
|
|
||||||
const msg = u.stringToElement(tpl_file_progress(
|
const msg = u.stringToElement(tpl_file_progress(
|
||||||
_.extend(this.model.toJSON(), {
|
_.extend(this.model.toJSON(), {
|
||||||
'filesize': filesize(this.model.get('file').size),
|
'filesize': filesize(this.model.get('file').size),
|
||||||
'image': image,
|
|
||||||
'image_type': image_type
|
|
||||||
})));
|
})));
|
||||||
return this.replaceElement(msg);
|
this.replaceElement(msg);
|
||||||
|
this.renderAvatar();
|
||||||
},
|
},
|
||||||
|
|
||||||
isMeCommand () {
|
isMeCommand () {
|
||||||
|
@ -169,6 +169,25 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ChatBoxHeading: {
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { _converse } = this.__super__,
|
||||||
|
{ __ } = _converse;
|
||||||
|
const result = this.__super__.render.apply(this, arguments);
|
||||||
|
const new_html = tpl_chatbox_minimize(
|
||||||
|
{info_minimize: __('Minimize this chat box')}
|
||||||
|
);
|
||||||
|
const el = this.el.querySelector('.toggle-chatbox-button');
|
||||||
|
if (el) {
|
||||||
|
el.outerHTML = new_html;
|
||||||
|
} else {
|
||||||
|
const button = this.el.querySelector('.close-chatbox-button');
|
||||||
|
button.insertAdjacentHTML('afterEnd', new_html);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
ChatRoomView: {
|
ChatRoomView: {
|
||||||
events: {
|
events: {
|
||||||
'click .toggle-chatbox-button': 'minimize',
|
'click .toggle-chatbox-button': 'minimize',
|
||||||
@ -522,20 +541,6 @@
|
|||||||
_converse.emit('minimizedChatsInitialized');
|
_converse.emit('minimizedChatsInitialized');
|
||||||
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
|
}).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
|
||||||
|
|
||||||
_converse.on('chatBoxOpened', function renderMinimizeButton (view) {
|
|
||||||
// Inserts a "minimize" button in the chatview's header
|
|
||||||
const new_html = tpl_chatbox_minimize(
|
|
||||||
{info_minimize: __('Minimize this chat box')}
|
|
||||||
);
|
|
||||||
const el = view.el.querySelector('.toggle-chatbox-button');
|
|
||||||
if (el) {
|
|
||||||
el.outerHTML = new_html;
|
|
||||||
} else {
|
|
||||||
const button = view.el.querySelector('.close-chatbox-button');
|
|
||||||
button.insertAdjacentHTML('afterEnd', new_html);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
_converse.on('controlBoxOpened', function (chatbox) {
|
_converse.on('controlBoxOpened', function (chatbox) {
|
||||||
// Wrapped in anon method because at scan time, chatboxviews
|
// Wrapped in anon method because at scan time, chatboxviews
|
||||||
// attr not set yet.
|
// attr not set yet.
|
||||||
|
@ -307,7 +307,6 @@
|
|||||||
return {
|
return {
|
||||||
'from': `${this.get('jid')}/${this.get('nick')}`,
|
'from': `${this.get('jid')}/${this.get('nick')}`,
|
||||||
'fullname': this.get('nick'),
|
'fullname': this.get('nick'),
|
||||||
'username': this.get('nick'),
|
|
||||||
'is_spoiler': is_spoiler,
|
'is_spoiler': is_spoiler,
|
||||||
'message': text ? u.httpToGeoUri(emojione.shortnameToUnicode(text), _converse) : undefined,
|
'message': text ? u.httpToGeoUri(emojione.shortnameToUnicode(text), _converse) : undefined,
|
||||||
'sender': 'me',
|
'sender': 'me',
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<div class="message chat-info chat-state-notification"
|
<div class="message chat-info chat-state-notification"
|
||||||
data-isodate="{{{o.isodate}}}"
|
data-isodate="{{{o.isodate}}}"
|
||||||
data-csn="{{{o.username}}}">{{{o.message}}}</div>
|
data-csn="{{{o.from}}}">{{{o.message}}}</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="message chat-msg" data-isodate="{{{o.time}}}" data-msgid="{{{o.msgid}}}">
|
<div class="message chat-msg" data-isodate="{{{o.time}}}" data-msgid="{{{o.msgid}}}">
|
||||||
<img alt="User Avatar" class="avatar" height="36px" width="36px" src="data:{{{o.image_type}}};base64,{{{o.image}}}"/>
|
<canvas class="avatar" height="36" width="36"></canvas>
|
||||||
<div class="chat-msg-content">
|
<div class="chat-msg-content">
|
||||||
<span class="chat-msg-text">Uploading file: <strong>{{{o.file.name}}}</strong>, {{{o.filesize}}}</span>
|
<span class="chat-msg-text">Uploading file: <strong>{{{o.file.name}}}</strong>, {{{o.filesize}}}</span>
|
||||||
<progress value="{{{o.progress}}}"/>
|
<progress value="{{{o.progress}}}"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user