Avoid inserting invalid dates and/or empty divs

This commit is contained in:
JC Brand 2018-10-24 22:42:46 +02:00
parent aac8b741b9
commit 53b1239964

View File

@ -536,6 +536,9 @@ converse.plugins.add('converse-chatview', {
prev_msg_date = _.isNull(prev_msg_el) ? null : prev_msg_el.getAttribute('data-isodate'),
next_msg_date = next_msg_el.getAttribute('data-isodate');
if (_.isNull(prev_msg_date) && _.isNull(next_msg_date)) {
return;
}
if (_.isNull(prev_msg_date) || moment(next_msg_date).isAfter(prev_msg_date, 'day')) {
const day_date = moment(next_msg_date).startOf('day');
next_msg_el.insertAdjacentHTML('beforeBegin',
@ -725,7 +728,10 @@ converse.plugins.add('converse-chatview', {
*/
const view = new _converse.MessageView({'model': message});
await view.render();
if (!view.el.innerHTML) {
return _converse.log("showMessage: message's view element is empty", Strophe.LogLevel.ERROR);
}
this.clearChatStateNotification(message);
this.insertMessage(view);
this.insertDayIndicator(view.el);