From 36dc3e4c5332d03e699dd062043bb2e922749342 Mon Sep 17 00:00:00 2001 From: mprakhov Date: Wed, 8 Feb 2023 16:45:54 +0200 Subject: [PATCH] fix(@desktop/chats): Scroll chat to the bottom or last unread msg when chat is first time opening --- .../AppLayouts/Chat/views/ChatColumnView.qml | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index 0d76cb58d6..dee64d0359 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -1,8 +1,9 @@ -import QtQuick 2.13 +import QtQuick 2.14 import Qt.labs.platform 1.1 -import QtQuick.Controls 2.13 -import QtQuick.Layouts 1.13 +import QtQuick.Controls 2.14 +import QtQuick.Layouts 1.14 import QtGraphicalEffects 1.0 +import QtQml 2.14 import Qt.labs.qmlmodels 1.0 import StatusQ.Core.Theme 0.1 @@ -118,13 +119,25 @@ Item { Repeater { id: chatRepeater model: parentModule && parentModule.model + delegate: Loader { id: chatLoader - // Channels are not loaded by default and only load when first put active - active: model.active - visible: active + + // Channels/chats are not loaded by default and only load when first put active + active: false width: parent.width height: parent.height + visible: model.active + + // Removing the binding in order not to unload the content: + // It is done for keeping: + // - the last channel/chat scroll position + // - the last typed but not sent text + Binding on active { + when: !chatLoader.active + restoreMode: Binding.RestoreNone + value: model.itemId && root.isSectionActive && (model.itemId === root.activeChatId || model.itemId === root.activeSubItemId) + } sourceComponent: ChatContentView { visible: !root.rootStore.openCreateChat && isActiveChannel