Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
adding default document dir and default return value
Browse files Browse the repository at this point in the history
  • Loading branch information
heilmela authored and heilerich committed Dec 28, 2020
1 parent 49535db commit be98f7e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ var app = new Vue({
importAccounts: {},
importTransactions: {},
accountMatch: {},
budgets: getBudgets().budgets,
selectedBudget: getBudgets().selectedBudget
budgets: getBudgets() ? getBudgets().budgets : [],
selectedBudget: getBudgets() ? getBudgets().selectedBudget : {}
},
computed: {
selectedAccountOb() {
Expand Down Expand Up @@ -209,10 +209,12 @@ function getBudgets() {
let path = os.homedir() + '/Library/Application Support/Actual/global-store.json'
let actualSettings = JSON.parse(fs.readFileSync(path))
this.selectedBudget = actualSettings['lastBudget']
this.budgets = fs.readdirSync(actualSettings['document-dir'], { withFileTypes: true })
let documentDir = actualSettings['document-dir'] || os.homedir() + '/Documents/Actual';
this.budgets = fs.readdirSync(documentDir, { withFileTypes: true })
.filter(dirent => dirent.isDirectory()).map(dirent => dirent.name)
} catch (error) {
console.error(error)
return {selectedBudget: '', budgets: []};
}
return {selectedBudget, budgets}
}
Expand Down

0 comments on commit be98f7e

Please sign in to comment.