add export function and button

This commit is contained in:
Jonathan Rainville 2020-12-18 15:15:00 -05:00 committed by Iuri Matias
parent 93376f0047
commit 82405cc425
4 changed files with 62 additions and 4 deletions

View File

@ -715,3 +715,10 @@ QtObject:
except Exception as e:
error "Error inviting to the community", msg = e.msg
result = fmt"Error inviting to the community: {e.msg}"
proc exportComumnity*(self: ChatsView): string {.slot.} =
try:
result = self.status.chat.exportCommunity(self.activeCommunity.communityItem.id)
except Exception as e:
error "Error exporting the community", msg = e.msg
result = fmt"Error exporting the community: {e.msg}"

View File

@ -397,3 +397,6 @@ proc inviteUserToCommunity*(self: ChatModel, communityId: string, pubKey: string
status_chat.inviteUserToCommunity(communityId, pubKey)
# After sending the invite, we send a message with the community ID so they can join
self.sendMessage(pubKey, "Upgrade here to see an invitation to community", "", ContentType.Community.int, communityId)
proc exportCommunity*(self: ChatModel, communityId: string): string =
result = status_chat.exportCommunity(communityId)

View File

@ -301,3 +301,6 @@ proc leaveCommunity*(communityId: string) =
proc inviteUserToCommunity*(communityId: string, pubKey: string) =
let res = callPrivateRPC("inviteUserToCommunity".prefix, %*[communityId, pubKey])#.parseJSON()["result"]
debug "RESULT", res
proc exportCommunity*(communityId: string):string =
result = callPrivateRPC("exportCommunity".prefix, %*[communityId]).parseJson()["result"].getStr

View File

@ -17,7 +17,7 @@ ModalPopup {
property string source: "../../../img/ens-header-dark@2x.png"
property int nbMembers: community.nbMembers
property bool isAdmin: true // TODO:
height: isAdmin ? 627 : 509
height: isAdmin ? 640 : 509
id: popup
@ -181,6 +181,7 @@ ModalPopup {
}
}
}
CommunityPopupButton {
id: notificationsBtn
label: qsTr("Notifications")
@ -199,9 +200,11 @@ ModalPopup {
}
}
}
Separator {
width: parent.width
}
Loader {
active: isAdmin
width: parent.width
@ -217,10 +220,52 @@ ModalPopup {
}
}
}
Loader {
property string exportResult: ""
active: isAdmin
width: parent.width
sourceComponent: !exportResult ? exportBtn : resultComponent
Component {
id: exportBtn
CommunityPopupButton {
label: qsTr("Export community")
iconName: "../fetch"
onClicked: exportResult = chatsModel.exportComumnity()
}
}
Component {
id: resultComponent
StyledText {
property bool isError: !exportResult.startsWith("0x")
text: exportResult
color: isError ? Style.current.danger : Style.current.textColor
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding + copyToClipboardBtn.width
wrapMode: TextEdit.WrapAnywhere
CopyToClipBoardButton {
id: copyToClipboardBtn
visible: !isError
textToCopy: exportResult
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.right
anchors.leftMargin: Style.current.smallPadding
}
}
}
}
CommunityPopupButton {
label: qsTr("Leave community")
iconName: "leave"
}
Loader {
active: isAdmin
width: parent.width