add export function and button
This commit is contained in:
parent
93376f0047
commit
82405cc425
|
@ -715,3 +715,10 @@ QtObject:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "Error inviting to the community", msg = e.msg
|
error "Error inviting to the community", msg = e.msg
|
||||||
result = fmt"Error inviting to the community: {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}"
|
||||||
|
|
|
@ -397,3 +397,6 @@ proc inviteUserToCommunity*(self: ChatModel, communityId: string, pubKey: string
|
||||||
status_chat.inviteUserToCommunity(communityId, pubKey)
|
status_chat.inviteUserToCommunity(communityId, pubKey)
|
||||||
# After sending the invite, we send a message with the community ID so they can join
|
# 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)
|
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)
|
|
@ -301,3 +301,6 @@ proc leaveCommunity*(communityId: string) =
|
||||||
proc inviteUserToCommunity*(communityId: string, pubKey: string) =
|
proc inviteUserToCommunity*(communityId: string, pubKey: string) =
|
||||||
let res = callPrivateRPC("inviteUserToCommunity".prefix, %*[communityId, pubKey])#.parseJSON()["result"]
|
let res = callPrivateRPC("inviteUserToCommunity".prefix, %*[communityId, pubKey])#.parseJSON()["result"]
|
||||||
debug "RESULT", res
|
debug "RESULT", res
|
||||||
|
|
||||||
|
proc exportCommunity*(communityId: string):string =
|
||||||
|
result = callPrivateRPC("exportCommunity".prefix, %*[communityId]).parseJson()["result"].getStr
|
|
@ -17,7 +17,7 @@ ModalPopup {
|
||||||
property string source: "../../../img/ens-header-dark@2x.png"
|
property string source: "../../../img/ens-header-dark@2x.png"
|
||||||
property int nbMembers: community.nbMembers
|
property int nbMembers: community.nbMembers
|
||||||
property bool isAdmin: true // TODO:
|
property bool isAdmin: true // TODO:
|
||||||
height: isAdmin ? 627 : 509
|
height: isAdmin ? 640 : 509
|
||||||
|
|
||||||
id: popup
|
id: popup
|
||||||
|
|
||||||
|
@ -181,6 +181,7 @@ ModalPopup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommunityPopupButton {
|
CommunityPopupButton {
|
||||||
id: notificationsBtn
|
id: notificationsBtn
|
||||||
label: qsTr("Notifications")
|
label: qsTr("Notifications")
|
||||||
|
@ -199,9 +200,11 @@ ModalPopup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Separator {
|
Separator {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
active: isAdmin
|
active: isAdmin
|
||||||
width: parent.width
|
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 {
|
CommunityPopupButton {
|
||||||
label: qsTr("Leave community")
|
label: qsTr("Leave community")
|
||||||
iconName: "leave"
|
iconName: "leave"
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
active: isAdmin
|
active: isAdmin
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
Loading…
Reference in New Issue