fix(@desktop/timeline): can't click the links and hashtags in timeline

This commit is contained in:
Andrei Smirnov 2021-07-07 18:08:05 +03:00 committed by Iuri Matias
parent 4d148b5c78
commit 1653e3bf20
4 changed files with 116 additions and 142 deletions

View File

@ -303,6 +303,9 @@ Item {
readonly property int maxGapInSeconds: Constants.maxNbDaysToFetch * Constants.fetchRangeLast24Hours readonly property int maxGapInSeconds: Constants.maxNbDaysToFetch * Constants.fetchRangeLast24Hours
visible: { visible: {
if (!chatsModel.activeChannel) {
return false
}
return gapNowAndOldest < maxGapInSeconds return gapNowAndOldest < maxGapInSeconds
&& gapNowAndJoined > maxGapInSeconds && gapNowAndJoined > maxGapInSeconds
&& (chatsModel.channelView.activeChannel.chatType !== Constants.chatTypePrivateGroupChat || chatsModel.channelView.activeChannel.isMember) && (chatsModel.channelView.activeChannel.chatType !== Constants.chatTypePrivateGroupChat || chatsModel.channelView.activeChannel.isMember)

View File

@ -42,7 +42,7 @@ Item {
color: Style.current.textColor color: Style.current.textColor
height: root.veryLongChatText && !root.readMore ? Math.min(implicitHeight, 200) : implicitHeight height: root.veryLongChatText && !root.readMore ? Math.min(implicitHeight, 200) : implicitHeight
clip: height < implicitHeight clip: height < implicitHeight
onLinkActivated: function (link) { onLinkActivated: {
if(link.startsWith("#")) { if(link.startsWith("#")) {
const channelName = link.substring(1); const channelName = link.substring(1);
const chatType = chatsModel.communities.activeCommunity.active ? Constants.chatTypeCommunity : Constants.chatTypePublic; const chatType = chatsModel.communities.activeCommunity.active ? Constants.chatTypeCommunity : Constants.chatTypePublic;
@ -55,6 +55,7 @@ Item {
appMain.changeAppSection(Constants.chat) appMain.changeAppSection(Constants.chat)
} }
} else { } else {
appMain.changeAppSection(Constants.chat)
chatsModel.channelView.setActiveChannel(channelName); chatsModel.channelView.setActiveChannel(channelName);
} }

View File

@ -4,162 +4,132 @@ import "../../../../../shared"
import "../../../../../imports" import "../../../../../imports"
import "../../../../../shared/status" import "../../../../../shared/status"
Rectangle { MouseArea {
id: root id: root
property var clickMessage: function () {} property var clickMessage: function () {}
property bool hovered: containsMouse
property var container
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 0 anchors.topMargin: 0
height: (isImage ? chatImageContent.height : chatText.height) + chatName.height + 2* Style.current.padding + (emojiReactions !== "" ? 20 : 0) height: (isImage ? chatImageContent.height : chatText.height) + chatName.height + 2* Style.current.padding + (emojiReactions !== "" ? 20 : 0)
width: parent.width width: parent.width
radius: Style.current.radius hoverEnabled: true
color: hovered ? Style.current.border : Style.current.background cursorShape: Qt.PointingHandCursor
property bool hovered: false propagateComposedEvents: true
property var container onClicked: {
mouse.accepted = false
UserImage {
id: chatImage
active: isMessage || isImage
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
} }
UsernameLabel { Rectangle {
id: chatName id: rootRect
visible: chatImage.visible
anchors.leftMargin: Style.current.halfPadding
anchors.top: chatImage.top
anchors.left: chatImage.right
label.font.pixelSize: Style.current.primaryTextFontSize
z: 51
}
ChatTime {
id: chatTime
formatDateTime: true
visible: chatName.visible
anchors.verticalCenter: chatName.verticalCenter
anchors.left: chatName.right
anchors.leftMargin: Style.current.halfPadding
}
ChatText {
id: chatText
anchors.top: chatName.visible ? chatName.bottom : chatImage.top
anchors.topMargin: chatName.visible ? 6 : 0
anchors.left: chatImage.right
anchors.leftMargin: Style.current.halfPadding
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
mouse.accepted = false
}
onEntered: {
root.hovered = true
}
onExited: {
root.hovered = false
}
}
}
Loader {
id: chatImageContent
active: isImage
anchors.left: chatImage.right
anchors.leftMargin: Style.current.halfPadding
anchors.top: chatText.bottom
z: 51
sourceComponent: Component {
ChatImage {
imageSource: image
imageWidth: 200
onClicked: root.clickMessage(false, false, true, image)
container: root.container
}
}
}
MouseArea {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true radius: Style.current.radius
propagateComposedEvents: true color: root.hovered ? Style.current.border : Style.current.background
onEntered: {
if (!root.hovered) {
root.hovered = true
}
}
onExited: {
if (root.hovered) {
root.hovered = false
}
}
}
StatusIconButton { UserImage {
id: emojiBtn id: chatImage
visible: root.hovered active: isMessage || isImage
highlighted: visible anchors.left: parent.left
anchors.top: root.top anchors.leftMargin: Style.current.padding
anchors.topMargin: -height/2 anchors.top: parent.top
anchors.right: root.right anchors.topMargin: Style.current.halfPadding
anchors.rightMargin: Style.current.halfPadding }
highlightedIconColor: Style.current.secondaryText
highlightedBackgroundColor: Style.current.background UsernameLabel {
icon.name: "emoji" id: chatName
icon.width: 20 visible: chatImage.visible
icon.height: 20 anchors.leftMargin: Style.current.halfPadding
MouseArea { anchors.top: chatImage.top
anchors.fill: parent anchors.left: chatImage.right
hoverEnabled: true label.font.pixelSize: Style.current.primaryTextFontSize
cursorShape: Qt.PointingHandCursor z: 51
onClicked: root.clickMessage(false, false, false, null, true) }
onEntered: {
if (!root.hovered) { ChatTime {
root.hovered = true id: chatTime
} formatDateTime: true
} visible: chatName.visible
onExited: { anchors.verticalCenter: chatName.verticalCenter
if (root.hovered) { anchors.left: chatName.right
root.hovered = false anchors.leftMargin: Style.current.halfPadding
}
ChatText {
id: chatText
anchors.top: chatName.visible ? chatName.bottom : chatImage.top
anchors.topMargin: chatName.visible ? 6 : 0
anchors.left: chatImage.right
anchors.leftMargin: Style.current.halfPadding
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
}
Loader {
id: chatImageContent
active: isImage
anchors.left: chatImage.right
anchors.leftMargin: Style.current.halfPadding
anchors.top: chatText.bottom
z: 51
sourceComponent: Component {
ChatImage {
imageSource: image
imageWidth: 200
onClicked: root.clickMessage(false, false, true, image)
container: root.container
} }
} }
} }
}
DropShadow {
anchors.fill: emojiBtn
horizontalOffset: 0
verticalOffset: 2
radius: 10
samples: 12
color: "#22000000"
source: emojiBtn
}
Loader { StatusIconButton {
id: emojiReactionLoader id: emojiBtn
active: emojiReactions !== "" visible: root.hovered
sourceComponent: emojiReactionsComponent highlighted: visible
anchors.left: chatImage.right anchors.top: rootRect.top
anchors.leftMargin: Style.current.halfPadding anchors.topMargin: -height / 4
anchors.top: isImage ? chatImageContent.bottom : chatText.bottom anchors.right: rootRect.right
anchors.topMargin: Style.current.halfPadding anchors.rightMargin: Style.current.halfPadding
} highlightedIconColor: Style.current.secondaryText
highlightedBackgroundColor: Style.current.background
icon.name: "emoji"
icon.width: 20
icon.height: 20
onClicked: {
root.clickMessage(false, false, false, null, true)
}
}
Component { DropShadow {
id: emojiReactionsComponent anchors.fill: emojiBtn
EmojiReactions {} horizontalOffset: 0
} verticalOffset: 2
radius: 10
samples: 12
color: "#22000000"
source: emojiBtn
}
Separator { Loader {
anchors.bottom: parent.bottom id: emojiReactionLoader
visible: !root.hovered active: emojiReactions !== ""
sourceComponent: emojiReactionsComponent
anchors.left: chatImage.right
anchors.leftMargin: Style.current.halfPadding
anchors.top: isImage ? chatImageContent.bottom : chatText.bottom
anchors.topMargin: Style.current.halfPadding
}
Component {
id: emojiReactionsComponent
EmojiReactions {}
}
Separator {
anchors.bottom: parent.bottom
visible: !root.hovered
}
} }
} }

View File

@ -127,8 +127,8 @@ ScrollView {
fromAuthor: model.fromAuthor fromAuthor: model.fromAuthor
chatId: model.chatId chatId: model.chatId
userName: model.userName userName: model.userName
localName: model.localName
alias: model.alias alias: model.alias
localName: model.localName
message: model.message message: model.message
plainText: model.plainText plainText: model.plainText
identicon: model.identicon identicon: model.identicon