diff --git a/src/plugins/chatview/styles/chatbox.scss b/src/plugins/chatview/styles/chatbox.scss index 9978fdb35..00ad02f9c 100644 --- a/src/plugins/chatview/styles/chatbox.scss +++ b/src/plugins/chatview/styles/chatbox.scss @@ -138,13 +138,6 @@ flex-direction: column; justify-content: space-between; - converse-chat-content { - display: flex; - flex-direction: column; - height: 100%; - justify-content: space-between; - } - converse-chat-message { .spinner { width: 100%; diff --git a/src/plugins/chatview/view.js b/src/plugins/chatview/view.js index d1aa2bfa6..84ad1ac00 100644 --- a/src/plugins/chatview/view.js +++ b/src/plugins/chatview/view.js @@ -75,7 +75,6 @@ export default class ChatView extends BaseChatView { afterShown () { this.model.setChatState(_converse.ACTIVE); - this.scrollDown(); this.maybeFocus(); } } diff --git a/src/plugins/headlines-view/view.js b/src/plugins/headlines-view/view.js index 23e6d8cc1..7dea88d7b 100644 --- a/src/plugins/headlines-view/view.js +++ b/src/plugins/headlines-view/view.js @@ -25,7 +25,6 @@ class HeadlinesView extends BaseChatView { await this.model.messages.fetched; this.model.maybeShow(); - this.scrollDown(); /** * Triggered once the {@link _converse.HeadlinesBoxView} has been initialized * @event _converse#headlinesBoxViewInitialized diff --git a/src/plugins/muc-views/muc.js b/src/plugins/muc-views/muc.js index 4f2a9f5a1..e45d33eb0 100644 --- a/src/plugins/muc-views/muc.js +++ b/src/plugins/muc-views/muc.js @@ -21,15 +21,12 @@ export default class MUCView extends BaseChatView { this.listenTo(_converse, 'windowStateChanged', this.onWindowStateChanged); this.listenTo(this.model, 'change:composing_spoiler', this.requestUpdateMessageForm); - this.listenTo(this.model, 'change:hidden', () => this.afterShown()); - this.listenTo(this.model, 'change:minimized', () => this.afterShown()); this.listenTo(this.model, 'show', this.show); this.listenTo(this.model.session, 'change:connection_status', this.updateAfterTransition); this.listenTo(this.model.session, 'change:view', this.requestUpdate); this.updateAfterTransition(); this.model.maybeShow(); - this.scrollDown(); /** * Triggered once a { @link _converse.ChatRoomView } has been opened * @event _converse#chatRoomViewInitialized @@ -43,17 +40,6 @@ export default class MUCView extends BaseChatView { return tpl_muc({ 'model': this.model }); } - /** - * Callback method that gets called after the chat has become visible. - * @private - * @method _converse.ChatRoomView#afterShown - */ - afterShown () { - if (!this.model.get('hidden') && !this.model.get('minimized')) { - this.scrollDown(); - } - } - /** * Closes this chat, which implies leaving the MUC as well. * @private diff --git a/src/shared/chat/chat-content.js b/src/shared/chat/chat-content.js index 4614ecb0f..1db22813c 100644 --- a/src/shared/chat/chat-content.js +++ b/src/shared/chat/chat-content.js @@ -6,6 +6,8 @@ import { html } from 'lit'; import { onScrolledDown } from './utils.js'; import { safeSave } from '@converse/headless/utils/core.js'; +import './styles/chat-content.scss'; + export default class ChatContent extends CustomElement { @@ -17,12 +19,11 @@ export default class ChatContent extends CustomElement { connectedCallback () { super.connectedCallback(); - this.debouncedMaintainScroll = debounce(this.maintainScrollPosition, 100); this.markScrolled = debounce(this._markScrolled, 50); this.model = _converse.chatboxes.get(this.jid); this.listenTo(this.model, 'change:hidden_occupants', this.requestUpdate); - this.listenTo(this.model, 'change:scrolled', this.requestUpdate); + this.listenTo(this.model, 'change:scrolled', this.scrollDown); this.listenTo(this.model.messages, 'add', this.requestUpdate); this.listenTo(this.model.messages, 'change', this.requestUpdate); this.listenTo(this.model.messages, 'remove', this.requestUpdate); @@ -34,55 +35,22 @@ export default class ChatContent extends CustomElement { if (this.model.occupants) { this.listenTo(this.model.occupants, 'change', this.requestUpdate); } - // We jot down whether we were scrolled down before rendering, because when an - // image loads, it triggers 'scroll' and the chat will be marked as scrolled, - // which is technically true, but not what we want because the user - // didn't initiate the scrolling. - this.was_scrolled_up = this.model.get('scrolled'); - this.addEventListener('imageLoaded', () => { - this.debouncedMaintainScroll(); - }); this.addEventListener('scroll', () => this.markScrolled()); - this.initIntersectionObserver(); } render () { + // This element has "flex-direction: reverse", so elements here are + // shown in reverse order. return html` - ${ this.model.ui?.get('chat-content-spinner-top') ? html`` : '' } +