Commit 80e5a5a2 authored by JC Brand's avatar JC Brand

Explore how to not cause jitter when typing notifications appear

The idea is to have a separate container outside of the messages area
for showing notifications.

However, the extra space added by this container causes messages to look
like they're cut off prematurely when one scrolls up.

A redesign of the chat's textarea would be necessary to make things look
harmonious again.
parent 10fd902f
This diff is collapsed.
...@@ -69970,10 +69970,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -69970,10 +69970,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
if (_.isNull(prev_msg_date) || moment(next_msg_date).isAfter(prev_msg_date, 'day')) { if (_.isNull(prev_msg_date) || moment(next_msg_date).isAfter(prev_msg_date, 'day')) {
const day_date = moment(next_msg_date).startOf('day'); const day_date = moment(next_msg_date).startOf('day');
next_msg_el.insertAdjacentHTML('beforeBegin', tpl_new_day({
'isodate': day_date.format(), if (u.hasClass('chat-state-notification', next_msg_el)) {
'datestring': day_date.format("dddd MMM Do YYYY") next_msg_el.parentElement.insertAdjacentHTML('beforeBegin', tpl_new_day({
})); 'isodate': day_date.format(),
'datestring': day_date.format("dddd MMM Do YYYY")
}));
} else {
next_msg_el.insertAdjacentHTML('beforeBegin', tpl_new_day({
'isodate': day_date.format(),
'datestring': day_date.format("dddd MMM Do YYYY")
}));
}
} }
}, },
...@@ -70068,11 +70076,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -70068,11 +70076,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
}, },
clearChatStateNotification(message, isodate) { clearChatStateNotification(message, isodate) {
if (isodate) { this.el.querySelector('.chat-state-notifications').innerHTML = '';
_.each(sizzle(`.chat-state-notification[data-csn="${message.get('from')}"][data-isodate="${isodate}"]`, this.content), u.removeElement); },
} else {
_.each(sizzle(`.chat-state-notification[data-csn="${message.get('from')}"]`, this.content), u.removeElement); insertChatStateNotification(view) {
} const container = this.el.querySelector('.chat-state-notifications');
container.insertAdjacentElement('afterbegin', view.el);
}, },
shouldShowOnTextMessage() { shouldShowOnTextMessage() {
...@@ -70159,9 +70168,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -70159,9 +70168,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
'model': message 'model': message
}); });
this.clearChatStateNotification(message); this.clearChatStateNotification(message);
this.insertMessage(view);
this.insertDayIndicator(view.el); if (message.isOnlyChatStateNotification()) {
this.setScrollPosition(view.el); this.insertChatStateNotification(view);
} else {
this.insertMessage(view);
this.insertDayIndicator(view.el);
this.setScrollPosition(view.el);
}
if (u.isNewMessage(message)) { if (u.isNewMessage(message)) {
if (message.get('sender') === 'me') { if (message.get('sender') === 'me') {
...@@ -76257,6 +76271,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76257,6 +76271,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
this.el.innerHTML = tpl_chatroom(); this.el.innerHTML = tpl_chatroom();
this.renderHeading(); this.renderHeading();
this.renderChatArea(); this.renderChatArea();
this.renderMessageForm();
if (this.model.get('connection_status') !== converse.ROOMSTATUS.ENTERED) { if (this.model.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
this.showSpinner(); this.showSpinner();
...@@ -76276,14 +76291,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_ ...@@ -76276,14 +76291,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
if (_.isNull(this.el.querySelector('.chat-area'))) { if (_.isNull(this.el.querySelector('.chat-area'))) {
const container_el = this.el.querySelector('.chatroom-body'); const container_el = this.el.querySelector('.chatroom-body');
container_el.insertAdjacentHTML('beforeend', tpl_chatarea({ container_el.insertAdjacentHTML('beforeend', tpl_chatarea({
'label_message': __('Message'), 'show_send_button': _converse.show_send_button
'label_send': __('Send'),
'show_send_button': _converse.show_send_button,
'show_toolbar': _converse.show_toolbar,
'unread_msgs': __('You have unread messages')
})); }));
container_el.insertAdjacentElement('beforeend', this.occupantsview.el); container_el.insertAdjacentElement('beforeend', this.occupantsview.el);
this.renderToolbar(tpl_chatroom_toolbar);
this.content = this.el.querySelector('.chat-content'); this.content = this.el.querySelector('.chat-content');
this.toggleOccupants(null, true); this.toggleOccupants(null, true);
} }
...@@ -84346,31 +84356,13 @@ return __p ...@@ -84346,31 +84356,13 @@ return __p
var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./node_modules/lodash/escape.js")}; var _ = {escape:__webpack_require__(/*! ./node_modules/lodash/escape.js */ "./node_modules/lodash/escape.js")};
module.exports = function(o) { module.exports = function(o) {
var __t, __p = '', __e = _.escape, __j = Array.prototype.join; var __t, __p = '', __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') } function print() { __p += __j.call(arguments, '') }
__p += '<!-- src/templates/chatarea.html -->\n<div class="chat-area col">\n <div class="chat-content '; __p += '<!-- src/templates/chatarea.html -->\n<div class="chat-area col">\n <div class="chat-content ';
if (o.show_send_button) { ; if (o.show_send_button) { ;
__p += 'chat-content-sendbutton'; __p += 'chat-content-sendbutton';
} ; } ;
__p += '"></div>\n <div class="new-msgs-indicator hidden">▼ ' + __p += '"></div>\n <div class="message-form-container"/>\n</div>\n';
__e( o.unread_msgs ) +
' ▼</div>\n <form class="sendXMPPMessage">\n ';
if (o.show_toolbar) { ;
__p += '\n <ul class="chat-toolbar no-text-select"></ul>\n ';
} ;
__p += '\n <textarea type="text" class="chat-textarea ';
if (o.show_send_button) { ;
__p += 'chat-textarea-send-button';
} ;
__p += '"\n placeholder="' +
__e(o.label_message) +
'"></textarea>\n ';
if (o.show_send_button) { ;
__p += '\n <button type="submit" class="pure-button send-button">' +
__e( o.label_send ) +
'</button>\n ';
} ;
__p += '\n </form>\n</div>\n';
return __p return __p
}; };
...@@ -84391,7 +84383,7 @@ __p += '<!-- src/templates/chatbox.html -->\n<div class="flyout box-flyout">\n ...@@ -84391,7 +84383,7 @@ __p += '<!-- src/templates/chatbox.html -->\n<div class="flyout box-flyout">\n
if (o.show_send_button) { ; if (o.show_send_button) { ;
__p += 'chat-content-sendbutton'; __p += 'chat-content-sendbutton';
} ; } ;
__p += '"></div>\n <div class="message-form-container"/>\n </div>\n</div>\n'; __p += '"></div>\n <div class="chat-state-notifications"></div>\n <div class="message-form-container"/>\n </div>\n</div>\n';
return __p return __p
}; };
...@@ -197,6 +197,8 @@ ...@@ -197,6 +197,8 @@
border: 0; border: 0;
background-color: #ffffff; background-color: #ffffff;
line-height: 1.3em; line-height: 1.3em;
display: flex;
flex-direction: column;
video { video {
width: 100% width: 100%
......
#conversejs { #conversejs {
.message { .message {
flex-shrink: 0;
&.date-separator { &.date-separator {
height: 2em; height: 2em;
...@@ -37,9 +38,6 @@ ...@@ -37,9 +38,6 @@
&.badge { &.badge {
color: $chat-head-text-color; color: $chat-head-text-color;
} }
&.chat-state-notification {
font-style: italic;
}
&.chat-event { &.chat-event {
clear: left; clear: left;
font-style: italic; font-style: italic;
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
@import "chatrooms"; @import "chatrooms";
@import "headline"; @import "headline";
@import "messages"; @import "messages";
@import "csn";
@import "minimized_chats"; @import "minimized_chats";
@import "bookmarks"; @import "bookmarks";
@import "awesomplete"; @import "awesomplete";
......
...@@ -590,12 +590,21 @@ ...@@ -590,12 +590,21 @@
if (_.isNull(prev_msg_date) || moment(next_msg_date).isAfter(prev_msg_date, 'day')) { if (_.isNull(prev_msg_date) || moment(next_msg_date).isAfter(prev_msg_date, 'day')) {
const day_date = moment(next_msg_date).startOf('day'); const day_date = moment(next_msg_date).startOf('day');
next_msg_el.insertAdjacentHTML('beforeBegin', if (u.hasClass('chat-state-notification', next_msg_el)) {
tpl_new_day({ next_msg_el.parentElement.insertAdjacentHTML('beforeBegin',
'isodate': day_date.format(), tpl_new_day({
'datestring': day_date.format("dddd MMM Do YYYY") 'isodate': day_date.format(),
}) 'datestring': day_date.format("dddd MMM Do YYYY")
); })
);
} else {
next_msg_el.insertAdjacentHTML('beforeBegin',
tpl_new_day({
'isodate': day_date.format(),
'datestring': day_date.format("dddd MMM Do YYYY")
})
);
}
} }
}, },
...@@ -682,14 +691,12 @@ ...@@ -682,14 +691,12 @@
}, },
clearChatStateNotification (message, isodate) { clearChatStateNotification (message, isodate) {
if (isodate) { this.el.querySelector('.chat-state-notifications').innerHTML = '';
_.each( },
sizzle(`.chat-state-notification[data-csn="${message.get('from')}"][data-isodate="${isodate}"]`, this.content),
u.removeElement insertChatStateNotification (view) {
); const container = this.el.querySelector('.chat-state-notifications');
} else { container.insertAdjacentElement('afterbegin', view.el);
_.each(sizzle(`.chat-state-notification[data-csn="${message.get('from')}"]`, this.content), u.removeElement);
}
}, },
shouldShowOnTextMessage () { shouldShowOnTextMessage () {
...@@ -710,7 +717,7 @@ ...@@ -710,7 +717,7 @@
} }
} }
const current_msg_date = moment(view.model.get('time')) || moment, const current_msg_date = moment(view.model.get('time')) || moment,
previous_msg_date = this.getLastMessageDate(current_msg_date); previous_msg_date = this.getLastMessageDate(current_msg_date);
if (_.isNull(previous_msg_date)) { if (_.isNull(previous_msg_date)) {
this.content.insertAdjacentElement('afterbegin', view.el); this.content.insertAdjacentElement('afterbegin', view.el);
...@@ -773,10 +780,13 @@ ...@@ -773,10 +780,13 @@
*/ */
const view = new _converse.MessageView({'model': message}); const view = new _converse.MessageView({'model': message});
this.clearChatStateNotification(message); this.clearChatStateNotification(message);
this.insertMessage(view); if (message.isOnlyChatStateNotification()) {
this.insertDayIndicator(view.el); this.insertChatStateNotification(view);
this.setScrollPosition(view.el); } else {
this.insertMessage(view);
this.insertDayIndicator(view.el);
this.setScrollPosition(view.el);
}
if (u.isNewMessage(message)) { if (u.isNewMessage(message)) {
if (message.get('sender') === 'me') { if (message.get('sender') === 'me') {
// We remove the "scrolled" flag so that the chat area // We remove the "scrolled" flag so that the chat area
......
<div class="flyout box-flyout"> <div class="flyout box-flyout">
<div class="chat-body"> <div class="chat-body">
<div class="chat-content {[ if (o.show_send_button) { ]}chat-content-sendbutton{[ } ]}"></div> <div class="chat-content {[ if (o.show_send_button) { ]}chat-content-sendbutton{[ } ]}"></div>
<div class="chat-state-notifications"></div>
<div class="message-form-container"/> <div class="message-form-container"/>
</div> </div>
</div> </div>
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