austax: Refresh CGT adjustments list on update
This commit is contained in:
parent
22f1fb7bf5
commit
805cf4b319
@ -76,6 +76,7 @@
|
||||
<script setup lang="ts">
|
||||
import dayjs from 'dayjs';
|
||||
import { XCircleIcon } from '@heroicons/vue/24/solid';
|
||||
import { emit } from '@tauri-apps/api/event';
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
import { ref } from 'vue';
|
||||
|
||||
@ -144,6 +145,7 @@
|
||||
);
|
||||
}
|
||||
|
||||
await emit('cgt-adjustment-updated');
|
||||
await getCurrentWindow().close();
|
||||
}
|
||||
|
||||
@ -161,6 +163,7 @@
|
||||
[adjustment.id]
|
||||
);
|
||||
|
||||
await emit('cgt-adjustment-updated');
|
||||
await getCurrentWindow().close();
|
||||
}
|
||||
</script>
|
||||
|
@ -70,7 +70,8 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { PencilIcon } from '@heroicons/vue/24/outline';
|
||||
import { PlusIcon } from '@heroicons/vue/16/solid';
|
||||
import { ref } from 'vue';
|
||||
import { UnlistenFn, listen } from '@tauri-apps/api/event';
|
||||
import { onUnmounted, ref } from 'vue';
|
||||
|
||||
import { CGTAdjustment, cgtAssetCommodityName } from './cgt.ts';
|
||||
import { asCost } from '../../amounts.ts';
|
||||
@ -90,4 +91,17 @@
|
||||
}
|
||||
|
||||
load();
|
||||
|
||||
// Refresh CGT adjustments list when CGT adjustment updated
|
||||
let unlistenAdjustmentUpdated: UnlistenFn | null = null;
|
||||
(async () => {
|
||||
// Cannot await at top level without <Suspense> therefore do this in an async function
|
||||
unlistenAdjustmentUpdated = await listen('cgt-adjustment-updated', async (_event) => { await load(); });
|
||||
})();
|
||||
|
||||
onUnmounted(() => {
|
||||
if (unlistenAdjustmentUpdated !== null) {
|
||||
unlistenAdjustmentUpdated();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -87,6 +87,7 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { XCircleIcon } from '@heroicons/vue/24/solid';
|
||||
import { InformationCircleIcon } from '@heroicons/vue/20/solid';
|
||||
import { emit } from '@tauri-apps/api/event';
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||
import { ref } from 'vue';
|
||||
|
||||
@ -238,6 +239,7 @@
|
||||
}
|
||||
await dbTransaction.commit();
|
||||
|
||||
await emit('cgt-adjustment-updated');
|
||||
await getCurrentWindow().close();
|
||||
}
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user