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
visible: {
if (!chatsModel.activeChannel) {
return false
}
return gapNowAndOldest < maxGapInSeconds
&& gapNowAndJoined > maxGapInSeconds
&& (chatsModel.channelView.activeChannel.chatType !== Constants.chatTypePrivateGroupChat || chatsModel.channelView.activeChannel.isMember)

View File

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

View File

@ -4,162 +4,132 @@ import "../../../../../shared"
import "../../../../../imports"
import "../../../../../shared/status"
Rectangle {
MouseArea {
id: root
property var clickMessage: function () {}
property bool hovered: containsMouse
property var container
anchors.top: parent.top
anchors.topMargin: 0
height: (isImage ? chatImageContent.height : chatText.height) + chatName.height + 2* Style.current.padding + (emojiReactions !== "" ? 20 : 0)
width: parent.width
radius: Style.current.radius
color: hovered ? Style.current.border : Style.current.background
property bool hovered: false
property var container
UserImage {
id: chatImage
active: isMessage || isImage
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
propagateComposedEvents: true
onClicked: {
mouse.accepted = false
}
UsernameLabel {
id: chatName
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 {
Rectangle {
id: rootRect
anchors.fill: parent
hoverEnabled: true
propagateComposedEvents: true
onEntered: {
if (!root.hovered) {
root.hovered = true
}
}
onExited: {
if (root.hovered) {
root.hovered = false
}
}
}
radius: Style.current.radius
color: root.hovered ? Style.current.border : Style.current.background
StatusIconButton {
id: emojiBtn
visible: root.hovered
highlighted: visible
anchors.top: root.top
anchors.topMargin: -height/2
anchors.right: root.right
anchors.rightMargin: Style.current.halfPadding
highlightedIconColor: Style.current.secondaryText
highlightedBackgroundColor: Style.current.background
icon.name: "emoji"
icon.width: 20
icon.height: 20
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.clickMessage(false, false, false, null, true)
onEntered: {
if (!root.hovered) {
root.hovered = true
}
}
onExited: {
if (root.hovered) {
root.hovered = 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 {
id: chatName
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
}
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 {
id: emojiReactionLoader
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
}
StatusIconButton {
id: emojiBtn
visible: root.hovered
highlighted: visible
anchors.top: rootRect.top
anchors.topMargin: -height / 4
anchors.right: rootRect.right
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 {
id: emojiReactionsComponent
EmojiReactions {}
}
DropShadow {
anchors.fill: emojiBtn
horizontalOffset: 0
verticalOffset: 2
radius: 10
samples: 12
color: "#22000000"
source: emojiBtn
}
Separator {
anchors.bottom: parent.bottom
visible: !root.hovered
Loader {
id: emojiReactionLoader
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
chatId: model.chatId
userName: model.userName
localName: model.localName
alias: model.alias
localName: model.localName
message: model.message
plainText: model.plainText
identicon: model.identicon