diff --git a/src/app/chat/event_handling.nim b/src/app/chat/event_handling.nim index a530020916..cab28e0c05 100644 --- a/src/app/chat/event_handling.nim +++ b/src/app/chat/event_handling.nim @@ -41,6 +41,7 @@ proc handleChatEvents(self: ChatController) = self.status.events.on("sendingMessage") do(e:Args): var msg = MessageArgs(e) self.status.messages.trackMessage(msg.id, msg.channel) + self.view.sendingMessage() self.status.events.on("messageSent") do(e:Args): var msg = MessageSentArgs(e) diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index 3bd952d05a..d12bea23ba 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -117,6 +117,8 @@ QtObject: proc activeChannelChanged*(self: ChatsView) {.signal.} + proc sendingMessage*(self: ChatsView) {.signal.} + proc userNameOrAlias*(self: ChatsView, pubKey: string): string {.slot.} = if self.status.chat.contacts.hasKey(pubKey): return status_ens.userNameOrAlias(self.status.chat.contacts[pubKey]) diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml b/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml index 91885c716d..4efdb3042d 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml @@ -23,6 +23,11 @@ ScrollView { ScrollBar.horizontal.policy: ScrollBar.AlwaysOff function scrollToBottom(force, caller) { + if(force){ + Qt.callLater( chatLogView.positionViewAtEnd ) + return; + } + if (!chatLogView.atYEnd) { // User has scrolled up, we don't want to scroll back return @@ -53,6 +58,10 @@ ScrollView { scrollToBottom(true) } + onSendingMessage: { + scrollToBottom(true) + } + onMessagePushed: { scrollToBottom() } @@ -62,10 +71,15 @@ ScrollView { } } + property var loadMsgs : Backpressure.oneInTime(chatLogView, 500, function() { + if(loadingMessages) return; + loadingMessages = true; + chatsModel.loadMoreMessages(); + }); + onContentYChanged: { - if(atYBeginning && !loadingMessages){ - loadingMessages = true; - chatsModel.loadMoreMessages(); + if(scrollY < 500){ + loadMsgs(); } } diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatImage.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatImage.qml index 454fe9ffa8..dacaf95860 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatImage.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatImage.qml @@ -30,7 +30,7 @@ Rectangle { imageChatBox.height = 0 imageChatBox.visible = false } else if (imageMessage.status == Image.Ready) { - messageItem.scrollToBottom(true, messageItem) + messageItem.scrollToBottom(false, messageItem) } } } diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ImageMessage.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ImageMessage.qml index 46fcd3a0ce..a742f3ffed 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ImageMessage.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ImageMessage.qml @@ -44,7 +44,7 @@ Rectangle { imageChatBox.height = 0 imageChatBox.visible = false } else if (imageMessage.status == Image.Ready) { - messageItem.scrollToBottom(true, messageItem) + messageItem.scrollToBottom(false, messageItem) } } } diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/SentMessage.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/SentMessage.qml index 74f300e5c8..d6c3937219 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/SentMessage.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/SentMessage.qml @@ -4,7 +4,7 @@ import "../../../../../imports" StyledText { id: sentMessage - visible: isCurrentUser && !timeout && isMessage + visible: isCurrentUser && !timeout && !isExpired && isMessage color: Style.current.darkGrey text: outgoingStatus == "sent" ? //% "Sent"