chore: add safeguards when checking for community data in response

Also remove unnecessary signals
This commit is contained in:
Pascal Precht 2022-04-12 11:26:35 +02:00 committed by r4bbit.eth
parent 3f71e1fe87
commit 348516d5a5
2 changed files with 8 additions and 2 deletions

View File

@ -17,13 +17,11 @@ QtObject:
proc membersChanged*(self: ActiveSection) {.signal.} proc membersChanged*(self: ActiveSection) {.signal.}
proc pendingRequestsToJoinChanged*(self: ActiveSection) {.signal.} proc pendingRequestsToJoinChanged*(self: ActiveSection) {.signal.}
proc historyArchiveSupportEnabledChanged*(self: ActiveSection) {.signal.}
proc setActiveSectionData*(self: ActiveSection, item: SectionItem) = proc setActiveSectionData*(self: ActiveSection, item: SectionItem) =
self.item = item self.item = item
self.membersChanged() self.membersChanged()
self.pendingRequestsToJoinChanged() self.pendingRequestsToJoinChanged()
self.historyArchiveSupportEnabledChanged()
proc getId*(self: ActiveSection): string {.slot.} = proc getId*(self: ActiveSection): string {.slot.} =
return self.item.id return self.item.id

View File

@ -424,6 +424,14 @@ QtObject:
error "error: ", procName="joinCommunity", errDesription = "result is nil" error "error: ", procName="joinCommunity", errDesription = "result is nil"
return return
if not response.result.hasKey("communities") or response.result["communities"].kind != JArray or response.result["communities"].len == 0:
error "error: ", procName="joinCommunity", errDesription = "no 'communities' key in response"
return
if not response.result.hasKey("communitiesSettings") or response.result["communitiesSettings"].kind != JArray or response.result["communitiesSettings"].len == 0:
error "error: ", procName="joinCommunity", errDesription = "no 'communitiesSettings' key in response"
return
var updatedCommunity = response.result["communities"][0].toCommunityDto() var updatedCommunity = response.result["communities"][0].toCommunityDto()
let communitySettings = response.result["communitiesSettings"][0].toCommunitySettingsDto() let communitySettings = response.result["communitiesSettings"][0].toCommunitySettingsDto()