Skip to content

Commit

Permalink
Merge pull request #347 from Concordium/handle-new-schemas-when-impor…
Browse files Browse the repository at this point in the history
…ting

Fix importing web3Id credentials without the schemas already in storage
  • Loading branch information
shjortConcordium authored Aug 23, 2023
2 parents ff5deee + 573379e commit 1cc7398
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function updateList<T>(stored: T[], toAdd: T[], isEqual: (a: T, b: T) => boolean
function updateRecord<T>(
stored: Record<string, T>,
toAdd: Record<string, T>,
update: (updated: Record<string, T>) => void
update: (updated: Record<string, T>) => Promise<void>
) {
const updated = { ...stored };
Object.entries(toAdd).forEach(([key, value]) => {
Expand All @@ -70,7 +70,7 @@ function updateRecord<T>(
}
});

update(updated);
return update(updated);
}

export default function VerifiableCredentialImport() {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1cc7398

Please sign in to comment.