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

Commit

Permalink
fix: include typegroup when setting last fee (#1758)
Browse files Browse the repository at this point in the history
  • Loading branch information
dated committed Mar 9, 2020
1 parent 47f0792 commit 530765b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 19 deletions.
15 changes: 15 additions & 0 deletions __tests__/unit/store/modules/session.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,19 @@ describe('SessionModule', () => {
expect(store.getters['session/priceApi']).toEqual('coingecko')
})
})

describe('actions > setLastFeeByType', () => {
it('should set the value for the last fee by type', () => {
store.dispatch('session/setLastFeeByType', {
fee: '1000',
type: 0,
typeGroup: 1
})
expect(store.getters['session/lastFees']).toEqual({
1: {
0: '1000'
}
})
})
})
})
2 changes: 1 addition & 1 deletion src/renderer/components/Input/InputFee.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default {
}
},
lastFee () {
return this.$store.getters['session/lastFeeByType'](this.transactionType)
return this.$store.getters['session/lastFeeByType'](this.transactionType, this.transactionGroup)
},
feeChoiceMin () {
return this.feeChoices.MINIMUM
Expand Down
14 changes: 9 additions & 5 deletions src/renderer/components/Transaction/TransactionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<script>
import { camelCase, includes, findKey } from 'lodash'
import { upperFirst } from '@/utils'
import { TRANSACTION_TYPES } from '@config'
import { TRANSACTION_GROUPS, TRANSACTION_TYPES } from '@config'
import MultiSignature from '@/services/client-multisig'
import { ModalLoader, ModalWindow } from '@/components/Modal'
import TransactionForm from './TransactionForm'
Expand Down Expand Up @@ -230,7 +230,8 @@ export default {
this.storeTransaction(this.transaction)
this.updateLastFeeByType({
fee: this.transaction.fee.toString(),
type: this.transaction.type
type: this.transaction.type,
typeGroup: this.transaction.typeGroup || TRANSACTION_GROUPS.STANDARD
})
const { data } = response.body
Expand Down Expand Up @@ -351,14 +352,17 @@ export default {
})
},
updateLastFeeByType ({ fee, type }) {
this.$store.dispatch('session/setLastFeeByType', { fee, type })
updateLastFeeByType ({ fee, type, typeGroup }) {
this.$store.dispatch('session/setLastFeeByType', { fee, type, typeGroup })
this.$store.dispatch('profile/update', {
...this.session_profile,
lastFees: {
...this.session_profile.lastFees,
[type]: fee
[typeGroup]: {
...this.session_profile.lastFees[typeGroup],
[type]: fee
}
}
})
}
Expand Down
25 changes: 25 additions & 0 deletions src/renderer/store/migrations/2.8.2 - fix last fees.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { clone } from 'lodash'
import { TRANSACTION_GROUPS } from '@config'

export default store => {
store.getters['profile/all'].forEach(profile => {
const lastFees = profile.lastFees

if (lastFees === undefined || Object.keys(lastFees).length === 0) {
return
}

const updatedProfile = clone(profile)

updatedProfile.lastFees = {
[TRANSACTION_GROUPS.STANDARD]: {
...lastFees
}
}
console.log(updatedProfile.lastFees)

store.dispatch('profile/update', updatedProfile)
})

store.dispatch('app/setLatestAppliedMigration', '2.8.2')
}
22 changes: 9 additions & 13 deletions src/renderer/store/modules/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export default {
transactionTableRowCount: state => state.transactionTableRowCount,
unconfirmedVotes: state => state.unconfirmedVotes,
lastFees: state => state.lastFees,
lastFeeByType: state => type => {
return state.lastFees ? state.lastFees[type] : null
lastFeeByType: state => (type, typeGroup) => {
return (state.lastFees && state.lastFees[typeGroup]) ? state.lastFees[typeGroup][type] : null
},
multiSignaturePeer: state => state.multiSignaturePeer,
filterBlacklistedPlugins: state => state.filterBlacklistedPlugins,
Expand Down Expand Up @@ -203,8 +203,11 @@ export default {
state.unconfirmedVotes = votes
},

SET_LAST_FEES (state, fees) {
state.lastFees = fees
SET_LAST_FEES_BY_TYPE (state, { fee, type, typeGroup }) {
if (!state.lastFees[typeGroup]) {
state.lastFees[typeGroup] = {}
}
state.lastFees[typeGroup][type] = fee
},

SET_MULTI_SIGNATURE_PEER (state, peer) {
Expand Down Expand Up @@ -425,15 +428,8 @@ export default {
commit('SET_UNCONFIRMED_VOTES', value)
},

setLastFees ({ commit }, value) {
commit('SET_LAST_FEES', value)
},

setLastFeeByType ({ commit, getters }, { fee, type }) {
const fees = getters.lastFees
fees[type] = fee

commit('SET_LAST_FEES', fees)
setLastFeeByType ({ commit }, { fee, type, typeGroup }) {
commit('SET_LAST_FEES_BY_TYPE', { fee, type, typeGroup })
},

setMultiSignaturePeer ({ commit }, { host, port }) {
Expand Down

0 comments on commit 530765b

Please sign in to comment.