From 7255dcd2565b7a1b5e8269e1dfcc812686eda3dd Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Thu, 1 Jul 2021 16:48:47 +0300 Subject: [PATCH] Fixed: starting a group chat shouldn't show the section to fetch more messages. --- src/app/chat/views/chat_item.nim | 7 +++++++ ui/app/AppLayouts/Chat/ChatColumn/Message.qml | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/app/chat/views/chat_item.nim b/src/app/chat/views/chat_item.nim index 531e101d7c..a7a4eb3b26 100644 --- a/src/app/chat/views/chat_item.nim +++ b/src/app/chat/views/chat_item.nim @@ -171,6 +171,13 @@ QtObject: proc muted*(self: ChatItemView): bool {.slot.} = return ?.self.chatItem.muted + proc joined*(self: ChatItemView): string {.slot.} = + if self.chatItem.isNil: return "" + return $self.chatItem.joined + + QtProperty[string] joined: + read = joined + QtProperty[bool] muted: read = muted notify = mutedChanged diff --git a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml index 6beda1eba6..fc6ebb9c52 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml @@ -283,14 +283,21 @@ Item { id: fetchMoreMessagesButtonComponent Item { id: wrapper + property int gapNowAndOldest: nextMessageIndex > -1 ? (Date.now() / 1000 - nextMsgTimestamp / 1000) : 0 + property int gapNowAndJoined: Date.now() / 1000 - +chatsModel.channelView.activeChannel.joined / 1000 + + visible: { + return gapNowAndOldest < Constants.maxNbDaysToFetch * Constants.fetchRangeLast24Hours + && gapNowAndJoined > Constants.maxNbDaysToFetch * Constants.fetchRangeLast24Hours + && (chatsModel.activeChannel.chatType !== Constants.chatTypePrivateGroupChat || chatsModel.activeChannel.isMember) + } height: childrenRect.height + Style.current.smallPadding * 2 anchors.left: parent.left anchors.right: parent.right Separator { id: sep1 } - - Loader { + Loader { id: fetchLoaderIndicator anchors.top: sep1.bottom anchors.topMargin: Style.current.padding @@ -301,8 +308,7 @@ Item { width: 12 height: 12 } - } - + } StyledText { id: fetchMoreButton font.weight: Font.Medium