feat: implement load request ID for improved data loading consistency across views
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 52s

This commit is contained in:
Torsten Schulz (local)
2026-07-22 15:25:00 +02:00
parent 8e4edfb719
commit fd0b3020bf
5 changed files with 113 additions and 38 deletions

View File

@@ -483,6 +483,7 @@ export default {
data() {
return {
loading: false,
loadRequestId: 0,
saving: false,
transactionSaving: false,
loadError: '',
@@ -562,6 +563,7 @@ export default {
this.clearAccountsState();
return;
}
this.clearAccountsState();
await this.loadAccounts();
},
},
@@ -619,6 +621,8 @@ export default {
},
methods: {
clearAccountsState() {
this.loadRequestId += 1;
this.loading = false;
this.accounts = [];
this.transactions = [];
this.paymentClaims = [];
@@ -732,28 +736,34 @@ export default {
this.selectedTransactionId = null;
this.transactionForm = createEmptyTransactionForm(accountId);
},
async loadPaymentClaims() {
if (!this.currentClub) {
async loadPaymentClaims(clubId = this.currentClub, requestId = this.loadRequestId) {
if (!clubId) {
this.paymentClaims = [];
return;
}
try {
const response = await apiClient.get(`/club-payment-claims/${this.currentClub}`);
const response = await apiClient.get(`/club-payment-claims/${clubId}`);
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
this.paymentClaims = Array.isArray(response.data?.claims) ? response.data.claims : [];
} catch (_error) {
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
this.paymentClaims = [];
}
},
async loadAccounts() {
if (!this.currentClub) return;
const clubId = this.currentClub;
if (!clubId) return;
const requestId = ++this.loadRequestId;
this.loading = true;
this.loadError = '';
try {
const response = await apiClient.get(`/club-accounts/${this.currentClub}`);
const response = await apiClient.get(`/club-accounts/${clubId}`);
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
const entries = Array.isArray(response.data?.accounts) ? response.data.accounts : [];
this.accounts = entries.map(normalizeAccount);
this.transactions = Array.isArray(response.data?.transactions) ? response.data.transactions.map(normalizeTransaction) : [];
await this.loadPaymentClaims();
await this.loadPaymentClaims(clubId, requestId);
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
this.applyRouteQuery();
if (this.selectedAccountId && !this.selectedAccount) {
this.resetForm();
@@ -767,9 +777,10 @@ export default {
this.resetForm();
}
} catch (error) {
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
this.loadError = safeErrorMessage(error, 'Konten konnten nicht geladen werden.');
} finally {
this.loading = false;
if (requestId === this.loadRequestId) this.loading = false;
}
},
async submitAccount() {

View File

@@ -670,6 +670,7 @@ export default {
data() {
return {
loading: false,
loadRequestId: 0,
saving: false,
messageSaving: false,
groupSaving: false,
@@ -756,6 +757,7 @@ export default {
this.clearCommunicationState();
return;
}
this.clearCommunicationState();
await this.loadCommunication();
},
},
@@ -803,6 +805,8 @@ export default {
},
methods: {
clearCommunicationState() {
this.loadRequestId += 1;
this.loading = false;
this.threads = [];
this.groups = [];
this.members = [];
@@ -925,11 +929,14 @@ export default {
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
},
async loadCommunication() {
if (!this.currentClub) return;
const clubId = this.currentClub;
if (!clubId) return;
const requestId = ++this.loadRequestId;
this.loading = true;
this.loadError = '';
try {
const response = await apiClient.get(`/club-communication/${this.currentClub}`);
const response = await apiClient.get(`/club-communication/${clubId}`);
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
this.threads = Array.isArray(response.data?.threads) ? response.data.threads.map(normalizeThread) : [];
this.groups = Array.isArray(response.data?.groups) ? response.data.groups.map(normalizeGroup) : [];
this.members = Array.isArray(response.data?.members) ? response.data.members.map(normalizeMember) : [];
@@ -955,9 +962,10 @@ export default {
this.resetTemplateForm();
}
} catch (error) {
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
this.loadError = safeErrorMessage(error, 'Kommunikation konnte nicht geladen werden.');
} finally {
this.loading = false;
if (requestId === this.loadRequestId) this.loading = false;
}
},
selectThread(thread) {

View File

@@ -508,6 +508,7 @@ export default {
data() {
return {
loading: false,
loadRequestId: 0,
saving: false,
partySaving: false,
loadError: '',
@@ -619,6 +620,7 @@ export default {
this.clearInvoiceState();
return;
}
this.clearInvoiceState();
await this.loadInvoices();
},
},
@@ -682,6 +684,8 @@ export default {
},
methods: {
clearInvoiceState() {
this.loadRequestId += 1;
this.loading = false;
this.invoices = [];
this.parties = [];
this.accounts = [];
@@ -751,11 +755,14 @@ export default {
}).format(amount);
},
async loadInvoices() {
if (!this.currentClub) return;
const clubId = this.currentClub;
if (!clubId) return;
const requestId = ++this.loadRequestId;
this.loading = true;
this.loadError = '';
try {
const response = await apiClient.get(`/club-invoices/${this.currentClub}`);
const response = await apiClient.get(`/club-invoices/${clubId}`);
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
this.invoices = Array.isArray(response.data?.invoices) ? response.data.invoices.map(normalizeInvoice) : [];
this.parties = Array.isArray(response.data?.parties) ? response.data.parties.map(normalizeParty) : [];
this.accounts = Array.isArray(response.data?.accounts) ? response.data.accounts : [];
@@ -784,9 +791,10 @@ export default {
}
this.applyWorkflowQueryPrefill();
} catch (error) {
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
this.loadError = safeErrorMessage(error, 'Rechnungen konnten nicht geladen werden.');
} finally {
this.loading = false;
if (requestId === this.loadRequestId) this.loading = false;
}
},
selectInvoice(invoice) {

View File

@@ -444,6 +444,7 @@ export default {
data() {
return {
loading: false,
loadRequestId: 0,
saving: false,
materializing: false,
loadError: '',
@@ -516,6 +517,7 @@ export default {
this.clearTaskState();
return;
}
this.clearTaskState();
await this.loadTasks();
},
},
@@ -544,6 +546,8 @@ export default {
},
methods: {
clearTaskState() {
this.loadRequestId += 1;
this.loading = false;
this.tasks = [];
this.taskDefinitions = [];
this.taskSuggestions = [];
@@ -646,11 +650,14 @@ export default {
this.form = createEmptyTaskForm();
},
async loadTasks() {
if (!this.currentClub) return;
const clubId = this.currentClub;
if (!clubId) return;
const requestId = ++this.loadRequestId;
this.loading = true;
this.loadError = '';
try {
const response = await apiClient.get(`/club-tasks/${this.currentClub}`);
const response = await apiClient.get(`/club-tasks/${clubId}`);
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
const entries = Array.isArray(response.data?.tasks)
? response.data.tasks
: Array.isArray(response.data)
@@ -675,9 +682,10 @@ export default {
this.resetForm();
}
} catch (error) {
if (requestId !== this.loadRequestId || clubId !== this.currentClub) return;
this.loadError = safeErrorMessage(error, 'Aufgaben konnten nicht geladen werden.');
} finally {
this.loading = false;
if (requestId === this.loadRequestId) this.loading = false;
}
},
async submitTask() {