Skip to content

Commit

Permalink
Fix bug with "favorite" action
Browse files Browse the repository at this point in the history
  • Loading branch information
bellingard committed Dec 17, 2017
1 parent f91a9ca commit 3b56b2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/renderer/components/pages/Accounts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</div>
<div>
<v-btn icon class="blue--text darken-1" @click="switchFavorite">
<v-icon>{{ $repo.bankAccount(selectedAccount).favorite ? 'star' : 'star_border' }}</v-icon>
<v-icon>{{ this.isFavorite ? 'star' : 'star_border' }}</v-icon>
</v-btn>
<synchronize-modal :account="getAccountId()" @saved="refreshAccountData"></synchronize-modal>
<payee-finder-modal></payee-finder-modal>
Expand Down Expand Up @@ -172,6 +172,7 @@ export default {
favoritesOnly: false,
showClosed: false,
search: '',
isFavorite: this.getAccountId() != null ? this.$repo.bankAccount(this.getAccountId()).favorite : false,
transactions: this.retrieveTransactions(),
accountBalance: this.computeAccountBalance(),
editTransaction: null,
Expand All @@ -191,26 +192,27 @@ export default {
},
watch: {
selectedAccount: function(newAccount) {
this.isFavorite = this.$repo.bankAccount(this.getAccountId()).favorite
this.transactions = this.retrieveTransactions()
this.accountBalance = this.computeAccountBalance()
}
},
methods: {
getAccountId() {
return this.selectedAccount == null ? this.accountId : this.selectedAccount
},
retrieveTransactions() {
return this.getAccountId() != null ? this.$repo.transactionsForAccount(this.getAccountId()) : []
},
computeAccountBalance() {
return this.getAccountId() != null ? this.$repo.getAccountBalance(this.getAccountId()) : ''
},
getAccountId() {
return this.selectedAccount == null ? this.accountId : this.selectedAccount
},
refreshAccountData() {
this.transactions = this.retrieveTransactions()
this.accountBalance = this.computeAccountBalance()
},
switchFavorite() {
this.$repo.changeFavorite(this.getAccountId())
this.isFavorite = this.$repo.changeFavorite(this.getAccountId())
},
// methods to manage the edition of transactions
openEditModal(transaction) {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/services/Repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default class Repo {
changeFavorite(accountId) {
let isFavorite = this.bankAccount(accountId).favorite
this.bankAccount(accountId).favorite = !isFavorite
return !isFavorite
}

addPayee(payeeName) {
Expand Down

0 comments on commit 3b56b2d

Please sign in to comment.