From 573379e153bae769b24c008235a385b4746c1040 Mon Sep 17 00:00:00 2001 From: Hjort Date: Tue, 22 Aug 2023 10:23:33 +0200 Subject: [PATCH] Wait for schemas and metadata to be saved before displaying imported credentials --- .../VerifiableCredentialImport.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/browser-wallet/src/popup/pages/VerifiableCredentialBackup/VerifiableCredentialImport.tsx b/packages/browser-wallet/src/popup/pages/VerifiableCredentialBackup/VerifiableCredentialImport.tsx index 2c53f88d2..5314bece5 100644 --- a/packages/browser-wallet/src/popup/pages/VerifiableCredentialBackup/VerifiableCredentialImport.tsx +++ b/packages/browser-wallet/src/popup/pages/VerifiableCredentialBackup/VerifiableCredentialImport.tsx @@ -61,7 +61,7 @@ function updateList(stored: T[], toAdd: T[], isEqual: (a: T, b: T) => boolean function updateRecord( stored: Record, toAdd: Record, - update: (updated: Record) => void + update: (updated: Record) => Promise ) { const updated = { ...stored }; Object.entries(toAdd).forEach(([key, value]) => { @@ -70,7 +70,7 @@ function updateRecord( } }); - update(updated); + return update(updated); } export default function VerifiableCredentialImport() { @@ -100,8 +100,8 @@ export default function VerifiableCredentialImport() { (a, b) => a.id === b.id, setVerifiableCredentials ); - updateRecord(storedSchemas.value, schemas, setSchemas); - updateRecord(storedMetadata.value, metadata, setMetadata); + await updateRecord(storedSchemas.value, schemas, setSchemas); + await updateRecord(storedMetadata.value, metadata, setMetadata); setImported(filteredCredentials); } } catch (e) {