Sweet @vlad nice one Thanks for open sourcing this resource.
I found an issue where you must scroll to see new messages on other clients than yourself.
The optimal way would be to have the app update on new message via the “websocket subscribe” it currently uses to fetch data. Currently I`m not too familiar with the on data changed functionality under workflows, but we can do a workaround by creating a pseudo field which is hidden and linked to the messages:last. Then we monitor that field for changes and execute a scroll to bottom when a change occurs.
Additionally, when a new message is detected we want to not scroll down when a user has scrolled up to read a message higher up. But to show some sort of notification displayed after the repeatinggroup of messages and before the newmessage box. This has to be done via custom javascript hidden in a custom-html-element which is set to a condition to display when the ondatachange fires.
This can be done either with both function and execution stored in the custom-html-element, or just function-execution there and the full js function loaded via the site settings custom javascript. Jquery seems to be loaded so we could do something like this to check if the scrollposition of a div is at bottom or not.
function isScrolledToBottom(el) {
var $el = $(el);
return el.scrollHeight - $el.scrollTop() - $el.outerHeight() < 1;
}