add import for a community
This commit is contained in:
parent
82405cc425
commit
a90a30af11
|
@ -722,3 +722,9 @@ QtObject:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "Error exporting the community", msg = e.msg
|
error "Error exporting the community", msg = e.msg
|
||||||
result = fmt"Error exporting the community: {e.msg}"
|
result = fmt"Error exporting the community: {e.msg}"
|
||||||
|
|
||||||
|
proc importCommunity*(self: ChatsView, communityKey: string) {.slot.} =
|
||||||
|
try:
|
||||||
|
self.status.chat.importCommunity(communityKey)
|
||||||
|
except Exception as e:
|
||||||
|
error "Error importing the community", msg = e.msg
|
|
@ -399,4 +399,7 @@ proc inviteUserToCommunity*(self: ChatModel, communityId: string, pubKey: string
|
||||||
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 =
|
proc exportCommunity*(self: ChatModel, communityId: string): string =
|
||||||
result = status_chat.exportCommunity(communityId)
|
result = status_chat.exportCommunity(communityId)
|
||||||
|
|
||||||
|
proc importCommunity*(self: ChatModel, communityKey: string) =
|
||||||
|
status_chat.importCommunity(communityKey)
|
|
@ -303,4 +303,8 @@ proc inviteUserToCommunity*(communityId: string, pubKey: string) =
|
||||||
debug "RESULT", res
|
debug "RESULT", res
|
||||||
|
|
||||||
proc exportCommunity*(communityId: string):string =
|
proc exportCommunity*(communityId: string):string =
|
||||||
result = callPrivateRPC("exportCommunity".prefix, %*[communityId]).parseJson()["result"].getStr
|
result = callPrivateRPC("exportCommunity".prefix, %*[communityId]).parseJson()["result"].getStr
|
||||||
|
|
||||||
|
proc importCommunity*(communityKey: string) =
|
||||||
|
let res = callPrivateRPC("importCommunity".prefix, %*[communityKey])
|
||||||
|
debug "RESULT", res
|
|
@ -126,12 +126,27 @@ ModalPopup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
footer: StatusButton {
|
footer: Item {
|
||||||
text: qsTr("Create a community")
|
anchors.fill: parent
|
||||||
anchors.right: parent.right
|
|
||||||
onClicked: {
|
StatusButton {
|
||||||
openPopup(createCommunitiesPopupComponent)
|
text: qsTr("Import a community")
|
||||||
popup.close()
|
anchors.right: createBtn.left
|
||||||
|
anchors.rightMargin: Style.current.smallPadding
|
||||||
|
onClicked: {
|
||||||
|
openPopup(importCommunitiesPopupComponent)
|
||||||
|
popup.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusButton {
|
||||||
|
id: createBtn
|
||||||
|
text: qsTr("Create a community")
|
||||||
|
anchors.right: parent.right
|
||||||
|
onClicked: {
|
||||||
|
openPopup(createCommunitiesPopupComponent)
|
||||||
|
popup.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls 2.3
|
||||||
|
import QtGraphicalEffects 1.13
|
||||||
|
import QtQuick.Dialogs 1.3
|
||||||
|
import "../../../../imports"
|
||||||
|
import "../../../../shared"
|
||||||
|
import "../../../../shared/status"
|
||||||
|
|
||||||
|
ModalPopup {
|
||||||
|
property string keyValidationError: ""
|
||||||
|
|
||||||
|
id: popup
|
||||||
|
height: 300
|
||||||
|
|
||||||
|
onOpened: {
|
||||||
|
keyInput.text = isEdit ? community.name : "";
|
||||||
|
keyInput.forceActiveFocus(Qt.MouseFocusReason)
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate() {
|
||||||
|
keyValidationError = ""
|
||||||
|
|
||||||
|
if (keyInput.text === "") {
|
||||||
|
keyValidationError = qsTr("You need to enter a key")
|
||||||
|
}
|
||||||
|
|
||||||
|
return !keyValidationError
|
||||||
|
}
|
||||||
|
|
||||||
|
title: qsTr("Import a community")
|
||||||
|
|
||||||
|
|
||||||
|
Input {
|
||||||
|
id: keyInput
|
||||||
|
label: qsTr("Community key")
|
||||||
|
placeholderText: qsTr("0x...")
|
||||||
|
validationError: popup.keyValidationError
|
||||||
|
}
|
||||||
|
|
||||||
|
footer: StatusButton {
|
||||||
|
text: qsTr("Import")
|
||||||
|
anchors.right: parent.right
|
||||||
|
onClicked: {
|
||||||
|
if (!validate()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let communityKey = keyInput.text
|
||||||
|
if (!communityKey.startsWith("0x")) {
|
||||||
|
communityKey = "0x" + communityKey
|
||||||
|
}
|
||||||
|
|
||||||
|
const error = chatsModel.importCommunity(communityKey)
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
creatingError.text = error
|
||||||
|
return creatingError.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
// popup.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageDialog {
|
||||||
|
id: creatingError
|
||||||
|
title: qsTr("Error importing the community")
|
||||||
|
icon: StandardIcon.Critical
|
||||||
|
standardButtons: StandardButton.Ok
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -71,6 +71,15 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: importCommunitiesPopupComponent
|
||||||
|
ImportCommunityPopup {
|
||||||
|
onClosed: {
|
||||||
|
destroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: communityDetailPopup
|
id: communityDetailPopup
|
||||||
CommunityDetailPopup {
|
CommunityDetailPopup {
|
||||||
|
|
|
@ -177,6 +177,7 @@ DISTFILES += \
|
||||||
app/AppLayouts/Chat/CommunityComponents/CommunityWelcomeBanner.qml \
|
app/AppLayouts/Chat/CommunityComponents/CommunityWelcomeBanner.qml \
|
||||||
app/AppLayouts/Chat/CommunityComponents/CreateChannelPopup.qml \
|
app/AppLayouts/Chat/CommunityComponents/CreateChannelPopup.qml \
|
||||||
app/AppLayouts/Chat/CommunityComponents/CreateCommunityPopup.qml \
|
app/AppLayouts/Chat/CommunityComponents/CreateCommunityPopup.qml \
|
||||||
|
app/AppLayouts/Chat/CommunityComponents/ImportCommunityPopup.qml \
|
||||||
app/AppLayouts/Chat/CommunityComponents/InviteFriendsToCommunityPopup.qml \
|
app/AppLayouts/Chat/CommunityComponents/InviteFriendsToCommunityPopup.qml \
|
||||||
app/AppLayouts/Chat/ContactsColumn/AddChat.qml \
|
app/AppLayouts/Chat/ContactsColumn/AddChat.qml \
|
||||||
app/AppLayouts/Chat/ContactsColumn/ClosedEmptyView.qml \
|
app/AppLayouts/Chat/ContactsColumn/ClosedEmptyView.qml \
|
||||||
|
|
Loading…
Reference in New Issue