feat: show community invite component on community link

This commit is contained in:
Jonathan Rainville 2021-03-08 15:21:56 -05:00 committed by Iuri Matias
parent 5581fca41d
commit 62d10eba49
5 changed files with 32 additions and 11 deletions

View File

@ -265,7 +265,7 @@ proc toMessage*(jsonMsg: JsonNode, pk: string): Message =
timestamp: $jsonMsg{"timestamp"}.getInt,
whisperTimestamp: $jsonMsg{"whisperTimestamp"}.getInt,
outgoingStatus: $jsonMsg{"outgoingStatus"}.getStr,
isCurrentUser: $jsonMsg{"outgoingStatus"}.getStr == "sending" or $jsonMsg{"outgoingStatus"}.getStr == "sent",
isCurrentUser: pk == jsonMsg{"from"}.getStr,
stickerHash: "",
stickerPackId: -1,
parsedText: @[],

View File

@ -296,7 +296,11 @@ Item {
Component {
id: invitationBubble
InvitationBubble {}
InvitationBubble {
communityId: communityId
anchors.right: !appSettings.useCompactMode && isCurrentUser ? parent.right : undefined
anchors.rightMargin: Style.current.padding
}
}
}

View File

@ -6,25 +6,29 @@ import "./TransactionComponents"
import "../../../Wallet/data"
Item {
property string communityId
property var invitedCommunity
property int innerMargin: 12
property bool joined: false
property bool isLink: false
id: root
anchors.left: parent.left
height: childrenRect.height
width: rectangleBubbleLoader.width + chatImage.width
Component.onCompleted: {
chatsModel.communities.setObservedCommunity(communityId)
chatsModel.communities.setObservedCommunity(root.communityId)
root.invitedCommunity = chatsModel.communities.observedCommunity
}
UserImage {
id: chatImage
visible: authorCurrentMsg != authorPrevMsg && !isCurrentUser
visible: (!isLink && authorCurrentMsg !== authorPrevMsg && !isCurrentUser) ||
(appSettings.useCompactMode && isCurrentUser && authorCurrentMsg !== authorPrevMsg)
anchors.left: parent.left
anchors.leftMargin: Style.current.padding
anchors.leftMargin: visible ? Style.current.padding : 0
anchors.top: parent.top
}
@ -33,10 +37,9 @@ Item {
active: !!invitedCommunity
width: item.width
height: item.height
anchors.right: isCurrentUser ? parent.right : undefined
anchors.rightMargin: Style.current.padding
anchors.left: !isCurrentUser ? chatImage.right : undefined
anchors.leftMargin: Style.current.smallPadding
anchors.left: !isLink && (!isCurrentUser || (isCurrentUser === appSettings.useCompactMode)) ? chatImage.right : undefined
anchors.leftMargin: isLink ? 0 : Style.current.smallPadding
anchors.right: !appSettings.useCompactMode && isCurrentUser ? parent.right : undefined
sourceComponent: Component {
Rectangle {

View File

@ -36,6 +36,7 @@ Column {
property bool fetched: false
property var linkData
property int linkWidth: linksRepeater.width
active: true
Connections {
@ -116,6 +117,10 @@ Column {
const data = Utils.getLinkDataForStatusLinks(link)
if (data) {
linkData = data
if (data.communityId) {
return invitationBubble
}
return unfurledLinkComponent
}
@ -157,6 +162,15 @@ Column {
}
}
Component {
id: invitationBubble
InvitationBubble {
communityId: linkData.communityId
isLink: true
anchors.left: parent.left
}
}
Component {
id: unfurledLinkComponent
MessageBorder {
@ -216,8 +230,6 @@ Column {
}
}
}
Component {
id: enableLinkComponent

View File

@ -344,6 +344,7 @@ QtObject {
}
result.title = qsTr("Join the %1 community").arg(communityName)
result.communityId = communityId
result.callback = function () {
const isUserMemberOfCommunity = chatsModel.communities.isUserMemberOfCommunity(communityId)
if (isUserMemberOfCommunity) {
@ -380,6 +381,7 @@ QtObject {
return {
site: qsTr("Status app link"),
title: result.title,
communityId: result.communityId,
thumbnailUrl: "../../../../img/status.png",
contentType: "",
height: 0,