Auto refresh transaction list when transaction edited
This commit is contained in:
parent
cfe53e9be9
commit
2dd967f5a4
@ -104,6 +104,7 @@
|
|||||||
|
|
||||||
import { PlusIcon, XCircleIcon } from '@heroicons/vue/24/solid';
|
import { PlusIcon, XCircleIcon } from '@heroicons/vue/24/solid';
|
||||||
|
|
||||||
|
import { emit } from '@tauri-apps/api/event';
|
||||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
@ -271,6 +272,7 @@
|
|||||||
|
|
||||||
await dbTransaction.commit();
|
await dbTransaction.commit();
|
||||||
|
|
||||||
|
await emit('transaction-updated', {id: newTransaction.id});
|
||||||
await getCurrentWindow().close();
|
await getCurrentWindow().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<!--
|
<!--
|
||||||
DrCr: Web-based double-entry bookkeeping framework
|
DrCr: Web-based double-entry bookkeeping framework
|
||||||
Copyright (C) 2022–2024 Lee Yingtong Li (RunasSudo)
|
Copyright (C) 2022–2025 Lee Yingtong Li (RunasSudo)
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -40,7 +40,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { PlusIcon } from '@heroicons/vue/24/outline';
|
import { PlusIcon } from '@heroicons/vue/24/outline';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { UnlistenFn, listen } from '@tauri-apps/api/event';
|
||||||
|
|
||||||
|
import { onUnmounted, ref } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import { Transaction, db } from '../db.ts';
|
import { Transaction, db } from '../db.ts';
|
||||||
@ -74,4 +76,16 @@
|
|||||||
transactions.value = filteredTxnsWithIndexes.map(([t, _idx]) => t);
|
transactions.value = filteredTxnsWithIndexes.map(([t, _idx]) => t);
|
||||||
}
|
}
|
||||||
load();
|
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 (unlistenTransactionUpdated !== null) {
|
||||||
|
unlistenTransactionUpdated();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user