fix(@desktop/wallet2): Ensure app not crash when loading collectibles

fails
This commit is contained in:
Anthony Laibe 2021-08-23 09:52:31 +02:00 committed by Iuri Matias
parent 067ed7b255
commit 77927da284
1 changed files with 2 additions and 2 deletions

View File

@ -88,7 +88,7 @@ QtObject:
proc setCollectionsList(self: CollectiblesView, raw: string) {.slot.} = proc setCollectionsList(self: CollectiblesView, raw: string) {.slot.} =
var newData: seq[OpenseaCollection] = @[] var newData: seq[OpenseaCollection] = @[]
let collectionsJSON = parseJson(raw) let collectionsJSON = parseJson(raw)
if collectionsJSON["result"].kind != JNull: if not collectionsJSON{"result"}.isNil and collectionsJSON{"result"}.kind != JNull:
for jsonOpenseaCollection in collectionsJSON{"result"}: for jsonOpenseaCollection in collectionsJSON{"result"}:
let collection = jsonOpenseaCollection.toOpenseaCollection() let collection = jsonOpenseaCollection.toOpenseaCollection()
newData.add(collection) newData.add(collection)
@ -110,7 +110,7 @@ QtObject:
proc setAssetsList(self: CollectiblesView, raw: string) {.slot.} = proc setAssetsList(self: CollectiblesView, raw: string) {.slot.} =
var newData: seq[OpenseaAsset] = @[] var newData: seq[OpenseaAsset] = @[]
let assetsJSON = parseJson(raw) let assetsJSON = parseJson(raw)
if assetsJSON{"assets"}{"result"}.kind != JNull: if not assetsJSON{"assets"}{"result"}.isNil and assetsJSON{"assets"}{"result"}.kind != JNull:
for jsonOpenseaAsset in assetsJSON{"assets"}{"result"}: for jsonOpenseaAsset in assetsJSON{"assets"}{"result"}:
newData.add(jsonOpenseaAsset.toOpenseaAsset()) newData.add(jsonOpenseaAsset.toOpenseaAsset())