Skip to content

Commit

Permalink
fix: if current year is invalid (probably not possible), just use pre…
Browse files Browse the repository at this point in the history
…vious logic
  • Loading branch information
Hoverth committed Nov 14, 2024
1 parent 0042e50 commit 54b5841
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/store/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 54b5841

Please sign in to comment.