Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

poquito requests #2289

Merged
merged 24 commits into from
Mar 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ensure delegations are loaded
  • Loading branch information
Federico Kunze committed Mar 19, 2019
commit 188c4b4166a13f3ff505cbeaa40124989bd738dc
8 changes: 7 additions & 1 deletion app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
@@ -206,6 +206,7 @@ export default {
`lastHeader`,
`bondDenom`,
`delegates`,
`delegation`,
`distribution`,
`committedDelegations`,
`keybase`,
@@ -321,6 +322,7 @@ export default {
this.session.signedIn &&
waitTwentyBlocks &&
this.$route.name === `validator` &&
this.delegation.loaded &&
Number(this.myBond) > 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if you load this page first and the bond has not been loaded yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't run into that issue

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

) {
this.$store.dispatch(
@@ -332,7 +334,11 @@ export default {
}
},
mounted() {
if (this.session.signedIn && Number(this.myBond) > 0) {
if (
this.session.signedIn &&
this.delegation.loaded &&
Number(this.myBond) > 0
) {
this.$store.dispatch(
`getRewardsFromValidator`,
this.$route.params.validator
23 changes: 15 additions & 8 deletions test/unit/specs/components/staking/PageValidator.spec.js
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ const getters = {
globalPower: 4200,
loaded: true
},

delegation: { loaded: true },
committedDelegations: {
[validator.operator_address]: 0
},
@@ -265,7 +265,8 @@ describe(`PageValidator`, () => {
const $store = { dispatch: jest.fn() }
const myBond = 1
const $route = { params: { validator: `cosmos1address` } }
PageValidator.mounted.call({ session, $store, $route, myBond })
const delegation = { loaded: true }
PageValidator.mounted.call({ session, $store, $route, myBond, delegation })
expect($store.dispatch).toHaveBeenCalledWith(
`getRewardsFromValidator`,
$route.params.validator
@@ -288,7 +289,8 @@ describe(`PageValidator`, () => {
const $store = { dispatch: jest.fn() }
const myBond = 0
const $route = { params: { validator: `cosmos1address` } }
PageValidator.mounted.call({ session, $store, $route, myBond })
const delegation = { loaded: true }
PageValidator.mounted.call({ session, $store, $route, myBond, delegation })
expect($store.dispatch).not.toHaveBeenCalledWith(
`getRewardsFromValidator`,
$route.params.validator
@@ -306,8 +308,9 @@ describe(`PageValidator`, () => {
}
const myBond = 1
const newHeader = { height: `20` }
const delegation = { loaded: true }
PageValidator.watch.lastHeader.handler.call(
{ session, $store, $route, myBond },
{ session, $store, $route, myBond, delegation },
newHeader)
expect($store.dispatch).not.toHaveBeenCalledWith(
`getRewardsFromValidator`,
@@ -324,8 +327,9 @@ describe(`PageValidator`, () => {
}
const myBond = 1
const newHeader = { height: `30` }
const delegation = { loaded: true }
PageValidator.watch.lastHeader.handler.call(
{ session, $store, $route, myBond },
{ session, $store, $route, myBond, delegation },
newHeader)
expect($store.dispatch).not.toHaveBeenCalledWith(
`getRewardsFromValidator`,
@@ -342,8 +346,9 @@ describe(`PageValidator`, () => {
}
const myBond = 1
const newHeader = { height: `20` }
const delegation = { loaded: true }
PageValidator.watch.lastHeader.handler.call(
{ session, $store, $route, myBond },
{ session, $store, $route, myBond, delegation },
newHeader)
expect($store.dispatch).not.toHaveBeenCalledWith(
`getRewardsFromValidator`,
@@ -360,8 +365,9 @@ describe(`PageValidator`, () => {
}
const myBond = 0
const newHeader = { height: `30` }
const delegation = { loaded: true }
PageValidator.watch.lastHeader.handler.call(
{ session, $store, $route, myBond },
{ session, $store, $route, myBond, delegation },
newHeader)
expect($store.dispatch).not.toHaveBeenCalledWith(
`getRewardsFromValidator`,
@@ -384,8 +390,9 @@ describe(`PageValidator`, () => {
}
const myBond = 1
const newHeader = { height: `20` }
const delegation = { loaded: true }
PageValidator.watch.lastHeader.handler.call(
{ session, $store, $route, myBond },
{ session, $store, $route, myBond, delegation },
newHeader)
expect($store.dispatch).toHaveBeenCalledWith(
`getRewardsFromValidator`,