From ebffecd364812f10c76dcd0446d70e66032e5374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Wed, 17 May 2023 14:22:46 +0200 Subject: [PATCH] fix that transaction list on to revert does not have multiple items --- src/components/BalanceHeader.vue | 6 ++++-- src/store.ts | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/components/BalanceHeader.vue b/src/components/BalanceHeader.vue index d01c9e5..acb8542 100644 --- a/src/components/BalanceHeader.vue +++ b/src/components/BalanceHeader.vue @@ -10,8 +10,10 @@
-
- +
+
+ +
diff --git a/src/store.ts b/src/store.ts index 4acce56..94a03f4 100644 --- a/src/store.ts +++ b/src/store.ts @@ -131,14 +131,14 @@ export const useBalanceStore = defineStore({ user: FG.User, filter: | { - limit?: number; - offset?: number; - from?: Date; - to?: Date; - showReversals?: boolean; - showCancelled?: boolean; - descending?: boolean; - } + limit?: number; + offset?: number; + from?: Date; + to?: Date; + showReversals?: boolean; + showCancelled?: boolean; + descending?: boolean; + } | undefined = undefined ) { if (!filter) filter = { limit: 10 }; @@ -146,7 +146,13 @@ export const useBalanceStore = defineStore({ params: filter, }); data.transactions.forEach((t) => fixTransaction(t)); - if (data.transactions) this.transactions.push(...data.transactions); + if (data.transactions) { + data.transactions.forEach((t) => { + const idx = this.transactions.findIndex((x) => x.id === t.id); + if (idx == -1) this.transactions.push(t); + else this.transactions[idx] = t; + }); + } return data; },