From 54b5841d00f3a25be3ae15526d1ec3277fa8b6c8 Mon Sep 17 00:00:00 2001 From: Thomas Dickson Date: Thu, 14 Nov 2024 15:59:39 +1300 Subject: [PATCH] fix: if current year is invalid (probably not possible), just use previous logic --- src/store/state/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/store/state/index.ts b/src/store/state/index.ts index 3ec86d8b..0851279a 100644 --- a/src/store/state/index.ts +++ b/src/store/state/index.ts @@ -5,7 +5,7 @@ import { moveInArrays, readFile, remove, uuid } from '@utils'; import { DeepReadonly, inject, reactive, readonly, ShallowRef, shallowRef, watch } from 'vue'; import { migrateApplicationState } from './migrator'; import { AvailableCurrency, Budget, BudgetGroup, BudgetYear, DataState, DataStates, DataStateV1 } from './types'; -import { generateBudgetYearFromCurrent } from './utils'; +import { generateBudgetYear, generateBudgetYearFromCurrent } from './utils'; export const DATA_STORE_KEY = Symbol('DataStore'); @@ -184,8 +184,10 @@ export const createDataStore = (storage?: Storage): Store => { let data = state.years.find((v) => v.year === year); if (!data) { - //data = generateBudgetYear(year); data = generateBudgetYearFromCurrent(year, getCurrentYear()); + if (!data) { + data = generateBudgetYear(year); + } state.years.push(data); state.years.sort((a, b) => a.year - b.year); }