Skip to content

Commit

Permalink
An error occurs when trying to save changes in a domain title/vision …
Browse files Browse the repository at this point in the history
…due to parallel requests causing database lock.
  • Loading branch information
Günther Cwioro committed May 21, 2024
1 parent 03994cb commit b9407ed
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions frontend-vue/src/stores/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,25 @@ export const useDomainsStore = defineStore("domains", () => {
}

async function updateDomain(domainId: DomainId, update: UpdateDomain): Promise<Awaited<UseFetchReturn<Domain>>[]> {
const response = await Promise.all([
useFetch<Domain>(`/api/domains/${domainId}/shortName`).post({
const oldValue = domainByDomainId.value[domainId];
const response = [];
if (oldValue.shortName !== update.key) {
response.push(await useFetch<Domain>(`/api/domains/${domainId}/shortName`).post({

Check warning on line 79 in frontend-vue/src/stores/domains.ts

View workflow job for this annotation

GitHub Actions / build-frontend

Insert `⏎········`
shortName: update.key,

Check warning on line 80 in frontend-vue/src/stores/domains.ts

View workflow job for this annotation

GitHub Actions / build-frontend

Insert `··`
}),
useFetch<Domain>(`/api/domains/${domainId}/rename`).post({
name: update.name,
}),
useFetch<Domain>(`/api/domains/${domainId}/vision`).post({
}));

Check warning on line 81 in frontend-vue/src/stores/domains.ts

View workflow job for this annotation

GitHub Actions / build-frontend

Replace `})` with `··})⏎······`
}

if (oldValue.vision !== update.vision) {
response.push(await useFetch<Domain>(`/api/domains/${domainId}/vision`).post({

Check warning on line 85 in frontend-vue/src/stores/domains.ts

View workflow job for this annotation

GitHub Actions / build-frontend

Insert `⏎········`
vision: update.vision,

Check warning on line 86 in frontend-vue/src/stores/domains.ts

View workflow job for this annotation

GitHub Actions / build-frontend

Replace `········` with `··········`
}),
]);
}));

Check warning on line 87 in frontend-vue/src/stores/domains.ts

View workflow job for this annotation

GitHub Actions / build-frontend

Replace `})` with `··})⏎······`
}

if (oldValue.name !== update?.name) {
response.push(await useFetch<Domain>(`/api/domains/${domainId}/rename`).post({

Check warning on line 91 in frontend-vue/src/stores/domains.ts

View workflow job for this annotation

GitHub Actions / build-frontend

Insert `⏎········`
name: update.name,

Check warning on line 92 in frontend-vue/src/stores/domains.ts

View workflow job for this annotation

GitHub Actions / build-frontend

Insert `··`
}));

Check warning on line 93 in frontend-vue/src/stores/domains.ts

View workflow job for this annotation

GitHub Actions / build-frontend

Replace `})` with `··})⏎······`
}
if (response.find((r) => !r.response.value?.ok)) {
return response;
}
Expand Down

0 comments on commit b9407ed

Please sign in to comment.