From bfeee360428dbef8d48412df3a5ca3ec51605afa Mon Sep 17 00:00:00 2001 From: Dario Gabriel Lipicar Date: Mon, 8 Jan 2024 15:09:04 -0300 Subject: [PATCH] fix(@desktop/wallet): Handle collectibles with missing metadata in lists Fixes #13162 --- .../shared_models/collectibles_entry.nim | 23 +++++++++++-------- .../shared_models/collectibles_model.nim | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app/modules/shared_models/collectibles_entry.nim b/src/app/modules/shared_models/collectibles_entry.nim index d594bcf41b..ff60b68e79 100644 --- a/src/app/modules/shared_models/collectibles_entry.nim +++ b/src/app/modules/shared_models/collectibles_entry.nim @@ -70,7 +70,7 @@ QtObject: traits:{self.traits} )""" - proc getCollectiblUniqueID*(self: CollectiblesEntry): backend.CollectibleUniqueID = + proc getCollectibleUniqueID*(self: CollectiblesEntry): backend.CollectibleUniqueID = return self.id proc hasCollectibleData(self: CollectiblesEntry): bool = @@ -122,9 +122,10 @@ QtObject: proc nameChanged*(self: CollectiblesEntry) {.signal.} proc getName*(self: CollectiblesEntry): string {.slot.} = - if not self.hasCollectibleData(): - return "" - return self.data.collectibleData.get().name + if self.hasCollectibleData(): + result = self.data.collectibleData.get().name + if result == "": + result = "#" & self.getTokenIDAsString() QtProperty[string] name: read = getName @@ -205,9 +206,10 @@ QtObject: proc collectionNameChanged*(self: CollectiblesEntry) {.signal.} proc getCollectionName*(self: CollectiblesEntry): string {.slot.} = - if not self.hasCollectionData(): - return "" - return self.getCollectionData().name + if self.hasCollectionData(): + result = self.getCollectionData().name + if result == "": + result = self.getContractAddress() QtProperty[string] collectionName: read = getCollectionName @@ -244,9 +246,10 @@ QtObject: proc communityNameChanged*(self: CollectiblesEntry) {.signal.} proc getCommunityName*(self: CollectiblesEntry): string {.slot.} = - if not self.hasCommunityData(): - return "" - return self.getCommunityData().name + if self.hasCommunityData(): + result = self.getCommunityData().name + if result == "": + result = self.getCommunityID() QtProperty[string] communityName: read = getCommunityName diff --git a/src/app/modules/shared_models/collectibles_model.nim b/src/app/modules/shared_models/collectibles_model.nim index 806f235187..0bfdd45afa 100644 --- a/src/app/modules/shared_models/collectibles_model.nim +++ b/src/app/modules/shared_models/collectibles_model.nim @@ -340,7 +340,7 @@ QtObject: let entry = self.items[i] for j in countdown(updates.high, 0): let update = updates[j] - if entry.getCollectiblUniqueID() == update.id: + if entry.getCollectibleUniqueID() == update.id: entry.updateData(update) let index = self.createIndex(i, 0, nil) defer: index.delete