fix: fix chat not scrolling to bottom on load
This commit is contained in:
parent
f2d345fe6e
commit
e176443ceb
|
@ -25,6 +25,7 @@ proc handleChatEvents(self: ChatController) =
|
||||||
|
|
||||||
self.status.events.on("chatsLoaded") do(e:Args):
|
self.status.events.on("chatsLoaded") do(e:Args):
|
||||||
self.view.setActiveChannelByIndex(0)
|
self.view.setActiveChannelByIndex(0)
|
||||||
|
self.view.appReady()
|
||||||
|
|
||||||
self.status.events.on("channelJoined") do(e: Args):
|
self.status.events.on("channelJoined") do(e: Args):
|
||||||
var channel = ChannelArgs(e)
|
var channel = ChannelArgs(e)
|
||||||
|
|
|
@ -119,6 +119,8 @@ QtObject:
|
||||||
|
|
||||||
proc sendingMessage*(self: ChatsView) {.signal.}
|
proc sendingMessage*(self: ChatsView) {.signal.}
|
||||||
|
|
||||||
|
proc appReady*(self: ChatsView) {.signal.}
|
||||||
|
|
||||||
proc userNameOrAlias*(self: ChatsView, pubKey: string): string {.slot.} =
|
proc userNameOrAlias*(self: ChatsView, pubKey: string): string {.slot.} =
|
||||||
if self.status.chat.contacts.hasKey(pubKey):
|
if self.status.chat.contacts.hasKey(pubKey):
|
||||||
return status_ens.userNameOrAlias(self.status.chat.contacts[pubKey])
|
return status_ens.userNameOrAlias(self.status.chat.contacts[pubKey])
|
||||||
|
|
|
@ -23,12 +23,7 @@ ScrollView {
|
||||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||||
|
|
||||||
function scrollToBottom(force, caller) {
|
function scrollToBottom(force, caller) {
|
||||||
if(force){
|
if (!force && !chatLogView.atYEnd) {
|
||||||
Qt.callLater( chatLogView.positionViewAtEnd )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!chatLogView.atYEnd) {
|
|
||||||
// User has scrolled up, we don't want to scroll back
|
// User has scrolled up, we don't want to scroll back
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -48,7 +43,12 @@ ScrollView {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: timer
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|
||||||
target: chatsModel
|
target: chatsModel
|
||||||
onMessagesLoaded: {
|
onMessagesLoaded: {
|
||||||
loadingMessages = false;
|
loadingMessages = false;
|
||||||
|
@ -66,6 +66,13 @@ ScrollView {
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onAppReady: {
|
||||||
|
// Add an additionnal delay, since the app can be "ready" just milliseconds before the UI updated to show the chat
|
||||||
|
timer.setTimeout(function() {
|
||||||
|
scrollToBottom(true)
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
onMessageNotificationPushed: function(chatId, msg) {
|
onMessageNotificationPushed: function(chatId, msg) {
|
||||||
notificationWindow.notifyUser(chatId, msg)
|
notificationWindow.notifyUser(chatId, msg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
app/AppLayouts/Chat/ChatColumn/CompactMessage.qml \
|
app/AppLayouts/Chat/ChatColumn/CompactMessage.qml \
|
||||||
app/AppLayouts/Chat/ChatColumn/MessageComponents/ChannelIdentifier.qml \
|
app/AppLayouts/Chat/ChatColumn/MessageComponents/ChannelIdentifier.qml \
|
||||||
|
app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatImage.qml \
|
||||||
app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatReply \
|
app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatReply \
|
||||||
app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatReply.qml \
|
app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatReply.qml \
|
||||||
app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatText.qml \
|
app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatText.qml \
|
||||||
|
|
Loading…
Reference in New Issue