diff --git a/src/app/modules/main/communities/controller.nim b/src/app/modules/main/communities/controller.nim index c7860080f2..dda6ffe94f 100644 --- a/src/app/modules/main/communities/controller.nim +++ b/src/app/modules/main/communities/controller.nim @@ -330,9 +330,6 @@ proc getChatDetailsByIds*(self: Controller, chatIds: seq[string]): seq[ChatDto] proc requestCommunityInfo*(self: Controller, communityId: string, shard: Shard, importing: bool) = self.communityService.requestCommunityInfo(communityId, shard, importing) -proc importCommunity*(self: Controller, communityKey: string) = - self.communityService.asyncImportCommunity(communityKey) - proc setCommunityMuted*(self: Controller, communityId: string, mutedType: int) = self.communityService.setCommunityMuted(communityId, mutedType) diff --git a/src/app/modules/main/communities/io_interface.nim b/src/app/modules/main/communities/io_interface.nim index a3332ac402..ddde89d78a 100644 --- a/src/app/modules/main/communities/io_interface.nim +++ b/src/app/modules/main/communities/io_interface.nim @@ -80,9 +80,6 @@ method requestCommunityInfo*(self: AccessInterface, communityId: string, shardCl method requestCommunityInfo*(self: AccessInterface, communityId: string, shard: Shard, importing: bool) {.base.} = raise newException(ValueError, "No implementation available") -method importCommunity*(self: AccessInterface, communityKey: string) {.base.} = - raise newException(ValueError, "No implementation available") - method myRequestAdded*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/communities/module.nim b/src/app/modules/main/communities/module.nim index eb5e2600bc..f9e69c5f06 100644 --- a/src/app/modules/main/communities/module.nim +++ b/src/app/modules/main/communities/module.nim @@ -420,10 +420,6 @@ method userCanJoin*(self: Module, communityId: string): bool = method isMyCommunityRequestPending*(self: Module, communityId: string): bool = self.controller.isMyCommunityRequestPending(communityId) -method communityImported*(self: Module, community: CommunityDto) = - self.view.addOrUpdateItem(self.getCommunityItem(community)) - self.view.emitImportingCommunityStateChangedSignal(community.id, ImportCommunityState.Imported.int, errorMsg = "") - method communityDataImported*(self: Module, community: CommunityDto) = self.view.addItem(self.getCommunityItem(community)) self.buildTokensAndCollectiblesFromCommunities(@[community]) @@ -432,16 +428,9 @@ method communityDataImported*(self: Module, community: CommunityDto) = method communityInfoRequestFailed*(self: Module, communityId: string, errorMsg: string) = self.view.emitCommunityInfoRequestCompleted(communityId, errorMsg) -method importCommunity*(self: Module, communityId: string) = - self.view.emitImportingCommunityStateChangedSignal(communityId, ImportCommunityState.ImportingInProgress.int, errorMsg = "") - self.controller.importCommunity(communityId) - method onImportCommunityErrorOccured*(self: Module, communityId: string, error: string) = self.view.emitImportingCommunityStateChangedSignal(communityId, ImportCommunityState.ImportingError.int, error) -method onImportCommunityCancelled*(self: Module, communityId: string) = - self.view.emitImportingCommunityStateChangedSignal(communityId, ImportCommunityState.ImportingCanceled.int, errorMsg = "") - method requestExtractDiscordChannelsAndCategories*(self: Module, filesToImport: seq[string]) = self.view.setDiscordDataExtractionInProgress(true) self.controller.requestExtractDiscordChannelsAndCategories(filesToImport) diff --git a/src/app/modules/main/communities/view.nim b/src/app/modules/main/communities/view.nim index fff5e29178..40d5529f46 100644 --- a/src/app/modules/main/communities/view.nim +++ b/src/app/modules/main/communities/view.nim @@ -603,9 +603,6 @@ QtObject: proc isMyCommunityRequestPending*(self: View, communityId: string): bool {.slot.} = self.delegate.isMyCommunityRequestPending(communityId) - proc importCommunity*(self: View, communityKey: string) {.slot.} = - self.delegate.importCommunity(communityKey) - proc importingCommunityStateChanged*(self:View, communityId: string, state: int, errorMsg: string) {.signal.} proc emitImportingCommunityStateChangedSignal*(self: View, communityId: string, state: int, errorMsg: string) = self.importingCommunityStateChanged(communityId, state, errorMsg) diff --git a/src/app_service/service/community/async_tasks.nim b/src/app_service/service/community/async_tasks.nim index b92373d262..0acaefd0b6 100644 --- a/src/app_service/service/community/async_tasks.nim +++ b/src/app_service/service/community/async_tasks.nim @@ -225,23 +225,6 @@ const asyncCheckPermissionsToJoinTask: Task = proc(argEncoded: string) {.gcsafe, "error": e.msg, }) -type - AsyncImportCommunityTaskArg = ref object of QObjectTaskArg - communityKey: string - -const asyncImportCommunityTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = - let arg = decode[AsyncImportCommunityTaskArg](argEncoded) - try: - let response = status_go.importCommunity(arg.communityKey) - arg.finish(%* { - "response": response, - "error": "", - }) - except Exception as e: - arg.finish(%* { - "error": e.msg, - }) - type AsyncGetRevealedAccountsArg = ref object of QObjectTaskArg communityId: string diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index 324f44403a..f3e85ae947 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -1900,71 +1900,6 @@ QtObject: ) self.threadpool.start(arg) - proc asyncImportCommunity*(self: Service, communityKey: string) = - let arg = AsyncImportCommunityTaskArg( - tptr: cast[ByteAddress](asyncImportCommunityTask), - vptr: cast[ByteAddress](self.vptr), - slot: "onAsyncImportCommunityCompleted", - communityKey: communityKey, - ) - self.threadpool.start(arg) - - proc onAsyncImportCommunityCompleted*(self: Service, response: string) {.slot.} = - try: - let rpcResponseObj = response.parseJson - if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "": - raise newException(RpcException, rpcResponseObj["error"].getStr) - ## after `importCommunity` call everything should be handled in a slot cnnected to `SignalType.CommunityFound.event` - ## but because of insufficient data (chats details are missing) sent as a payload of that signal we're unable to do - ## that until `status-go` part gets improved in ragards of that. - - if rpcResponseObj["response"]{"error"}.kind != JNull: - let error = Json.decode(rpcResponseObj["response"]["error"].getStr, RpcError) - raise newException(RpcException, error.message) - - if rpcResponseObj["response"]{"result"} == nil or rpcResponseObj["response"]{"result"}.kind != JObject: - raise newException(RpcException, "response is empty or not an json object") - - var communityJArr: JsonNode - if not rpcResponseObj["response"]{"result"}.getProp("communities", communityJArr): - raise newException(RpcException, "there is no `communities` key in the response") - - if communityJArr.len == 0: - raise newException(RpcException, "`communities` array is empty in the response") - - var communitiesSettingsJArr: JsonNode - if not rpcResponseObj["response"]{"result"}.getProp("communitiesSettings", communitiesSettingsJArr): - raise newException(RpcException, "there is no `communitiesSettings` key in the response") - - if communitiesSettingsJArr.len == 0: - raise newException(RpcException, "`communitiesSettings` array is empty in the response") - - var communityDto = communityJArr[0].toCommunityDto() - let communitySettingsDto = communitiesSettingsJArr[0].toCommunitySettingsDto() - - communityDto.settings = communitySettingsDto - self.communities[communityDto.id] = communityDto - - var chatsJArr: JsonNode - if rpcResponseObj["response"]{"result"}.getProp("chats", chatsJArr): - for chatObj in chatsJArr: - let chatDto = chatObj.toChatDto(communityDto.id) - self.chatService.updateOrAddChat(chatDto) # we have to update chats stored in the chat service. - - for chat in communityDto.chats: - let fullChatId = communityDto.id & chat.id - var chatDetails = self.chatService.getChatById(fullChatId) - chatDetails.updateMissingFields(chat) - self.chatService.updateOrAddChat(chatDetails) # we have to update chats stored in the chat service. - - self.events.emit(SIGNAL_COMMUNITY_IMPORTED, CommunityArgs(community: communityDto)) - - except Exception as e: - error "Error importing the community: ", msg = e.msg - # We should apply some notification mechanism on the application level which will deal with errors and - # notify user about them. Till then we're using this way. - self.events.emit(SIGNAL_COMMUNITY_IMPORTED, CommunityArgs(error: "Error while importing the community")) - proc exportCommunity*(self: Service, communityId: string): string = try: let response = status_go.exportCommunity(communityId) diff --git a/src/backend/communities.nim b/src/backend/communities.nim index fc46869308..cf37bcc71c 100644 --- a/src/backend/communities.nim +++ b/src/backend/communities.nim @@ -457,9 +457,6 @@ proc requestCommunityInfo*(communityId: string, tryDatabase: bool, shardCluster: "waitForResponse": true }]) -proc importCommunity*(communityKey: string): RpcResponse[JsonNode] = - result = callPrivateRPC("importCommunity".prefix, %*[communityKey]) - proc exportCommunity*(communityId: string): RpcResponse[JsonNode] = result = callPrivateRPC("exportCommunity".prefix, %*[communityId]) diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index 6c8d95c0ac..9910c611f6 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -304,10 +304,6 @@ QtObject { args.bannerJsonStr, args.options.encrypted); } - function importCommunity(communityKey) { - root.communitiesModuleInst.importCommunity(communityKey); - } - function createCommunityCategory(categoryName, channels) { chatCommunitySectionModule.createCommunityCategory(categoryName, channels) } diff --git a/ui/app/AppLayouts/Communities/stores/CommunitiesStore.qml b/ui/app/AppLayouts/Communities/stores/CommunitiesStore.qml index 6e88cecda0..e1293f844f 100644 --- a/ui/app/AppLayouts/Communities/stores/CommunitiesStore.qml +++ b/ui/app/AppLayouts/Communities/stores/CommunitiesStore.qml @@ -95,10 +95,6 @@ QtObject { args.bannerJsonStr, args.options.encrypted); } - function importCommunity(communityKey) { - root.communitiesModuleInst.importCommunity(communityKey); - } - function getCommunityPublicKeyFromPrivateKey(privateKey) { return root.communitiesModuleInst.getCommunityPublicKeyFromPrivateKey(privateKey); } diff --git a/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml b/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml index 73af073b35..2e3d756122 100644 --- a/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml +++ b/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml @@ -205,10 +205,6 @@ QtObject { } } - function importCommunity(communityKey) { - root.communitiesModuleInst.importCommunity(communityKey); - } - function getCurrentVersion() { return aboutModuleInst.getCurrentVersion() }