Skip to content

Commit

Permalink
Simplify and fix useDatatypesMapper
Browse files Browse the repository at this point in the history
The problem was that we'd immediately return if `createMapper` had
previously been called in another calling stack. I think we don't need
to do any error handling here, and the loading state can simply be
`datatypesMapperStore.loading`.

Fixes #18549
  • Loading branch information
mvdbeek committed Jul 16, 2024
1 parent dc0ffcd commit 38859d9
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions client/src/composables/datatypesMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,11 @@ export function useDatatypesMapper() {
const datatypes: Ref<string[]> = ref([]);

async function getDatatypesMapper() {
try {
await datatypesMapperStore.createMapper();
datatypesMapper.value = datatypesMapperStore.datatypesMapper;
if (datatypesMapperStore.datatypesMapper) {
datatypes.value = datatypesMapperStore.datatypesMapper.datatypes;
}
} catch (e) {
console.error("unable to create datatypes mapper\n", e);
} finally {
datatypesMapperLoading.value = false;
}
if (!datatypesMapperStore.datatypesMapper) {
throw Error("Error creating datatypesMapper");
await datatypesMapperStore.createMapper();
datatypesMapperLoading.value = datatypesMapperStore.loading;
datatypesMapper.value = datatypesMapperStore.datatypesMapper;
if (datatypesMapperStore.datatypesMapper) {
datatypes.value = datatypesMapperStore.datatypesMapper.datatypes;
}
}

Expand Down

0 comments on commit 38859d9

Please sign in to comment.