Refresh journal/general ledger view when transaction updated

This commit is contained in:
RunasSudo 2025-05-28 21:22:44 +10:00
parent 62b7981224
commit b3defb562f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 26 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<!--
DrCr: Web-based double-entry bookkeeping framework
Copyright (C) 20222025 Lee Yingtong Li (RunasSudo)
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@ -63,6 +63,7 @@
import dayjs from 'dayjs';
import { PencilIcon, PlusIcon } from '@heroicons/vue/24/outline';
import { invoke } from '@tauri-apps/api/core';
import { UnlistenFn, listen } from '@tauri-apps/api/event';
import { onUnmounted, ref, watch } from 'vue';
import { Transaction } from '../db.ts';
@ -151,9 +152,20 @@
load();
// Refresh transaction list when transaction updated
let unlistenTransactionUpdated: UnlistenFn | null = null;
(async () => {
// Cannot await at top level without <Suspense> therefore do this in an async function
unlistenTransactionUpdated = await listen('transaction-updated', async (_event) => { await load(); });
})();
onUnmounted(() => {
if (clusterize !== null) {
clusterize.destroy();
}
if (unlistenTransactionUpdated !== null) {
unlistenTransactionUpdated();
}
});
</script>

View File

@ -1,6 +1,6 @@
<!--
DrCr: Web-based double-entry bookkeeping framework
Copyright (C) 20222025 Lee Yingtong Li (RunasSudo)
Copyright (C) 2022-2025 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@ -60,12 +60,10 @@
<script setup lang="ts">
import Clusterize from 'clusterize.js';
import dayjs from 'dayjs';
import { PencilIcon } from '@heroicons/vue/24/outline';
import { PlusIcon } from '@heroicons/vue/16/solid';
import { UnlistenFn, listen } from '@tauri-apps/api/event';
import { onUnmounted, ref, watch } from 'vue';
import { JoinedTransactionPosting, Transaction, db, joinedToTransactions } from '../db.ts';
@ -157,9 +155,20 @@
load();
// Refresh transaction list when transaction updated
let unlistenTransactionUpdated: UnlistenFn | null = null;
(async () => {
// Cannot await at top level without <Suspense> therefore do this in an async function
unlistenTransactionUpdated = await listen('transaction-updated', async (_event) => { await load(); });
})();
onUnmounted(() => {
if (clusterize !== null) {
clusterize.destroy();
}
if (unlistenTransactionUpdated !== null) {
unlistenTransactionUpdated();
}
});
</script>