From cbe6092c3383c8c6043930f50631d6fe7b1428d8 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 31 Jul 2018 11:31:16 +0200 Subject: [PATCH] Handle case where chat content is empty --- src/converse-muc-views.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/converse-muc-views.js b/src/converse-muc-views.js index 6118b09e9..ca9d6680d 100644 --- a/src/converse-muc-views.js +++ b/src/converse-muc-views.js @@ -1429,11 +1429,11 @@ showLeaveNotification (occupant) { const nick = occupant.get('nick'), stat = occupant.get('status'), - last_el = this.content.lastElementChild, - last_msg_date = last_el.getAttribute('data-isodate'); + last_el = this.content.lastElementChild; - if (_.includes(_.get(last_el, 'classList', []), 'chat-info') && - moment(last_msg_date).isSame(new Date(), "day") && + if (last_el && + _.includes(_.get(last_el, 'classList', []), 'chat-info') && + moment(last_el.getAttribute('data-isodate')).isSame(new Date(), "day") && _.get(last_el, 'dataset', {}).join === `"${nick}"`) { let message; @@ -1462,7 +1462,8 @@ 'extra_classes': 'chat-event', 'data': `data-leave="${nick}"` } - if (_.includes(_.get(last_el, 'classList', []), 'chat-info') && + if (last_el && + _.includes(_.get(last_el, 'classList', []), 'chat-info') && _.get(last_el, 'dataset', {}).leavejoin === `"${nick}"`) { last_el.outerHTML = tpl_info(data);