fix: process community info requests fails (#12357)

This commit is contained in:
Igor Sirotin 2023-10-07 09:47:48 +01:00 committed by GitHub
parent 338e6f5fa9
commit 3321708629
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 9 deletions

View File

@ -85,7 +85,7 @@ proc init*(self: Controller) =
self.events.on(SIGNAL_COMMUNITY_LOAD_DATA_FAILED) do(e: Args): self.events.on(SIGNAL_COMMUNITY_LOAD_DATA_FAILED) do(e: Args):
let args = CommunityArgs(e) let args = CommunityArgs(e)
self.delegate.onImportCommunityErrorOccured(args.community.id, args.error) self.delegate.onImportCommunityErrorOccured(args.communityId, args.error)
self.events.on(SIGNAL_COMMUNITY_INFO_ALREADY_REQUESTED) do(e: Args): self.events.on(SIGNAL_COMMUNITY_INFO_ALREADY_REQUESTED) do(e: Args):
self.delegate.communityInfoAlreadyRequested() self.delegate.communityInfoAlreadyRequested()

View File

@ -28,6 +28,7 @@ logScope:
type type
CommunityArgs* = ref object of Args CommunityArgs* = ref object of Args
community*: CommunityDto community*: CommunityDto
communityId*: string # should be set when community is nil (i.e. error occured)
error*: string error*: string
fromUserAction*: bool fromUserAction*: bool
@ -1428,17 +1429,20 @@ QtObject:
proc asyncCommunityInfoLoaded*(self: Service, communityIdAndRpcResponse: string) {.slot.} = proc asyncCommunityInfoLoaded*(self: Service, communityIdAndRpcResponse: string) {.slot.} =
let rpcResponseObj = communityIdAndRpcResponse.parseJson let rpcResponseObj = communityIdAndRpcResponse.parseJson
if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "":
error "Error requesting community info", msg = rpcResponseObj{"error"}
return
var community = rpcResponseObj{"response"}{"result"}.toCommunityDto()
let requestedCommunityId = rpcResponseObj{"communityId"}.getStr() let requestedCommunityId = rpcResponseObj{"communityId"}.getStr()
self.requestedCommunityIds.excl(requestedCommunityId) self.requestedCommunityIds.excl(requestedCommunityId)
if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "":
error "Error requesting community info", msg = rpcResponseObj{"error"}
self.events.emit(SIGNAL_COMMUNITY_LOAD_DATA_FAILED, CommunityArgs(communityId: requestedCommunityId, error: "Couldn't find community info"))
return
var community = rpcResponseObj{"response"}{"result"}.toCommunityDto()
if community.id == "": if community.id == "":
community.id = requestedCommunityId community.id = requestedCommunityId
self.events.emit(SIGNAL_COMMUNITY_LOAD_DATA_FAILED, CommunityArgs(community: community, error: "Couldn't find community info")) self.events.emit(SIGNAL_COMMUNITY_LOAD_DATA_FAILED, CommunityArgs(communityId: requestedCommunityId, community: community, error: "Couldn't find community info"))
return return
self.communities[community.id] = community self.communities[community.id] = community

View File

@ -308,7 +308,6 @@ Item {
target: appMain.communitiesStore target: appMain.communitiesStore
function onImportingCommunityStateChanged(communityId, state, errorMsg) { function onImportingCommunityStateChanged(communityId, state, errorMsg) {
const community = appMain.communitiesStore.getCommunityDetailsAsJson(communityId)
let title = "" let title = ""
let subTitle = "" let subTitle = ""
let loading = false let loading = false
@ -318,6 +317,7 @@ Item {
switch (state) switch (state)
{ {
case Constants.communityImported: case Constants.communityImported:
const community = appMain.communitiesStore.getCommunityDetailsAsJson(communityId)
if(community.isControlNode) { if(community.isControlNode) {
title = qsTr("This device is now the control node for the %1 Community").arg(community.name) title = qsTr("This device is now the control node for the %1 Community").arg(community.name)
notificationType = Constants.ephemeralNotificationType.success notificationType = Constants.ephemeralNotificationType.success
@ -331,7 +331,7 @@ Item {
loading = true loading = true
break break
case Constants.communityImportingError: case Constants.communityImportingError:
title = qsTr("Failed to import community '%1'").arg(community.name) title = qsTr("Failed to import community '%1'").arg(communityId)
subTitle = errorMsg subTitle = errorMsg
break break
default: default:

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 80f25d5ff7828478d27cbbf2af474be578b79f08 Subproject commit da3df63eb19a0a267caf67e6fcdf2d5a8291b888