add import for a community
This commit is contained in:
parent
82405cc425
commit
a90a30af11
|
@ -722,3 +722,9 @@ QtObject:
|
|||
except Exception as e:
|
||||
error "Error exporting the community", msg = 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
|
|
@ -400,3 +400,6 @@ proc inviteUserToCommunity*(self: ChatModel, communityId: string, pubKey: string
|
|||
|
||||
proc exportCommunity*(self: ChatModel, communityId: string): string =
|
||||
result = status_chat.exportCommunity(communityId)
|
||||
|
||||
proc importCommunity*(self: ChatModel, communityKey: string) =
|
||||
status_chat.importCommunity(communityKey)
|
|
@ -304,3 +304,7 @@ proc inviteUserToCommunity*(communityId: string, pubKey: string) =
|
|||
|
||||
proc exportCommunity*(communityId: string):string =
|
||||
result = callPrivateRPC("exportCommunity".prefix, %*[communityId]).parseJson()["result"].getStr
|
||||
|
||||
proc importCommunity*(communityKey: string) =
|
||||
let res = callPrivateRPC("importCommunity".prefix, %*[communityKey])
|
||||
debug "RESULT", res
|
|
@ -126,7 +126,21 @@ ModalPopup {
|
|||
}
|
||||
}
|
||||
|
||||
footer: StatusButton {
|
||||
footer: Item {
|
||||
anchors.fill: parent
|
||||
|
||||
StatusButton {
|
||||
text: qsTr("Import a community")
|
||||
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: {
|
||||
|
@ -134,5 +148,6 @@ ModalPopup {
|
|||
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 {
|
||||
id: communityDetailPopup
|
||||
CommunityDetailPopup {
|
||||
|
|
|
@ -177,6 +177,7 @@ DISTFILES += \
|
|||
app/AppLayouts/Chat/CommunityComponents/CommunityWelcomeBanner.qml \
|
||||
app/AppLayouts/Chat/CommunityComponents/CreateChannelPopup.qml \
|
||||
app/AppLayouts/Chat/CommunityComponents/CreateCommunityPopup.qml \
|
||||
app/AppLayouts/Chat/CommunityComponents/ImportCommunityPopup.qml \
|
||||
app/AppLayouts/Chat/CommunityComponents/InviteFriendsToCommunityPopup.qml \
|
||||
app/AppLayouts/Chat/ContactsColumn/AddChat.qml \
|
||||
app/AppLayouts/Chat/ContactsColumn/ClosedEmptyView.qml \
|
||||
|
|
Loading…
Reference in New Issue