Chat : Stay at end.

This commit is contained in:
Julien Wadel 2023-03-28 09:20:46 +02:00
parent 4a1cfe0c91
commit 39cb5db106
4 changed files with 7 additions and 18 deletions

View file

@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## 5.1.0 - undefined ## 5.1.0 - undefined
### Added ### Added
- VFS Encryption - VFS Encryption
- File viewer in chats (Image/Animated Image/Video/Texts) with the option to export the file. - File viewer in chats (Image/Animated Image/Video/Texts) with the option to export the file.
@ -15,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Fixed ## Fixed
- Fix using only username in URI handlers. - Fix using only username in URI handlers.
- Chat flickering on load.
## 5.0.14 - 2023-03-16 ## 5.0.14 - 2023-03-16

View file

@ -12,6 +12,7 @@ ListView {
property alias horizontalScrollPolicy : hScrollBar.policy property alias horizontalScrollPolicy : hScrollBar.policy
property bool fitCacheToContent: true property bool fitCacheToContent: true
property bool bindToEnd: false
function getVisibleIndex(checkMax) { function getVisibleIndex(checkMax) {
var center_x = view.x + view.width / 2 var center_x = view.x + view.width / 2
@ -59,10 +60,11 @@ ListView {
contentHeight: height - (hScrollBar.visible?hScrollBar.height:0) contentHeight: height - (hScrollBar.visible?hScrollBar.height:0)
spacing: 0 spacing: 0
synchronousDrag: true synchronousDrag: true
onBindToEndChanged: if(bindToEnd) positionViewAtEnd()
onContentHeightChanged: { onContentHeightChanged: {
if(fitCacheToContent) if(fitCacheToContent)
cacheBuffer= (view.contentHeight > 0 ? view.contentHeight : 0) cacheBuffer= (view.contentHeight > 0 ? view.contentHeight : 0)
if(bindToEnd) positionViewAtEnd()
} }
cacheBuffer: height > 0 ? height : 0 cacheBuffer: height > 0 ? height : 0
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View file

@ -30,11 +30,11 @@
function initView () { function initView () {
chat.bindToEnd = true chat.bindToEnd = true
chat.positionViewAtEnd()
if(chat.atYBeginning && !chat.loadingEntries){//Check if we are at beginning if(chat.atYBeginning && !chat.loadingEntries){//Check if we are at beginning
chat.displaying = true chat.displaying = true
container.proxyModel.loadMoreEntriesAsync() container.proxyModel.loadMoreEntriesAsync()
} }
chat.positionViewAtEnd()
} }
function getComponentFromEntry (chatEntry) { function getComponentFromEntry (chatEntry) {

View file

@ -57,7 +57,6 @@ Rectangle {
ScrollableListView { ScrollableListView {
id: chat id: chat
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
property bool bindToEnd: false
property bool displaying: false property bool displaying: false
property bool loadingEntries: (container.proxyModel.chatRoomModel && container.proxyModel.chatRoomModel.entriesLoading) || displaying property bool loadingEntries: (container.proxyModel.chatRoomModel && container.proxyModel.chatRoomModel.entriesLoading) || displaying
property bool tryToLoadMoreEntries: loadingEntries || remainingLoadersCount>0 property bool tryToLoadMoreEntries: loadingEntries || remainingLoadersCount>0
@ -462,20 +461,5 @@ Rectangle {
}// ColumnLayout }// ColumnLayout
}// Bottom background }// Bottom background
} }
// ---------------------------------------------------------------------------
// Scroll at end if necessary.
// ---------------------------------------------------------------------------
Timer {
interval: 100
repeat: true
running: true
onTriggered: chat.bindToEnd && chat.positionViewAtEnd()
}
} }