Skip to content

Open source personal finance application

feat: persist history filter state

Ilya Komichev5961b8ef4882
diff --git a/app/components/trns/List.vue b/app/components/trns/List.vue
index 2f7ba911..6a18f2c0 100644
--- a/app/components/trns/List.vue
+++ b/app/components/trns/List.vue
@@ -251,7 +251,7 @@ const groupedTrns = computed(() => paginatedTrnsIds.value
<div
v-for="(groupTrnsIds, date) in groupedTrns"
:key="date"
- class="_bg-item-2 _rounded-lg overflow-hidden border-b border-item-4 pb-2"
+ class="_bg-item-2 _rounded-lg overflow-hidden border-b border-item-4 pb-2 last:border-b-0 last:pb-px"
>
<div
:class="{ 'border-item-4': isShowGroupSum && groupTrnsIds.length > 1 }"
diff --git a/app/components/trns/pages/History.vue b/app/components/trns/pages/History.vue
index 21f862f1..7b46d91b 100644
--- a/app/components/trns/pages/History.vue
+++ b/app/components/trns/pages/History.vue
@@ -1,4 +1,9 @@
<script setup lang="ts">
+import { useStorage } from '@vueuse/core'
+
+import type { CategoryId } from '~/components/categories/types'
+import type { WalletId } from '~/components/wallets/types'
+
import { useFilter } from '~/components/filter/useFilter'
import { useTrnsStore } from '~/components/trns/useTrnsStore'
@@ -17,6 +22,26 @@ const trnsIds = computed(() => trnsStore.getStoreTrnsIds({
}, {
includesChildCategories: true,
}))
+
+const lastFilter = useStorage<{
+ categoriesIds: CategoryId[]
+ walletsIds: WalletId[]
+}>('finapp.history.lastFilter2', {
+ categoriesIds: [],
+ walletsIds: [],
+}, localStorage, {
+ mergeDefaults: true,
+})
+
+onMounted(() => {
+ filter.setCategories(lastFilter.value.categoriesIds ?? [])
+ filter.setWallets(lastFilter.value.walletsIds ?? [])
+})
+
+watch([filter.categoriesIds, filter.walletsIds], () => {
+ lastFilter.value.categoriesIds = filter.categoriesIds.value
+ lastFilter.value.walletsIds = filter.walletsIds.value
+})
</script>
<template>
@@ -33,7 +58,7 @@ const trnsIds = computed(() => trnsStore.getStoreTrnsIds({
<template v-if="filter.isShow.value" #selected>
<FilterSelected
- class="sticky top-[40px] z-20 bg-item-2"
+ class="pb-2"
isShowCategories
isShowWallets
/>