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

fedekunze/1718 remove session pt 1 #1916

Merged
merged 25 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
app/dist
builds/*
task/builds
tasks/builds
coverage
node_modules
npm-debug.log
Expand Down
9 changes: 8 additions & 1 deletion app/src/renderer/components/common/AppMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<menu class="app-menu">
<div class="app-menu-main">
<router-link
v-if="user.signedIn"
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
id="app-menu__wallet"
class="app-menu-item"
to="/"
Expand All @@ -13,6 +14,7 @@
<i class="material-icons">chevron_right</i>
</router-link>
<router-link
v-if="user.signedIn"
id="app-menu__transactions"
class="app-menu-item"
to="/transactions"
Expand All @@ -26,7 +28,8 @@
<router-link
id="app-menu__staking"
class="app-menu-item"
to="/staking"
to="/staking/validators/"
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
exact="exact"
title="Staking"
@click.native="close"
>
Expand All @@ -49,6 +52,7 @@
</template>

<script>
import { mapGetters } from "vuex"
import PerfectScrollbar from "perfect-scrollbar"
import noScroll from "no-scroll"
import ConnectedNetwork from "common/TmConnectedNetwork"
Expand All @@ -59,6 +63,9 @@ export default {
ConnectedNetwork,
TmListItem
},
computed: {
...mapGetters([`user`])
},
data: () => ({
ps: {}
}),
Expand Down
9 changes: 6 additions & 3 deletions app/src/renderer/components/common/TmBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
<div class="icon-container">
<img class="icon" src="~assets/images/cosmos-logo.png" />
</div>
<div class="total-atoms top-section">
<div v-if="user.signedIn" class="total-atoms top-section">
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
<h3>Total {{ bondDenom }}</h3>
<h2 class="total-atoms__value">{{ num.shortNumber(totalAtoms) }}</h2>
</div>
<div v-if="unbondedAtoms" class="unbonded-atoms top-section">
<div
v-if="unbondedAtoms && user.signedIn"
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
class="unbonded-atoms top-section"
>
<h3>Available {{ bondDenom }}</h3>
<h2>{{ unbondedAtoms }}</h2>
</div>
</div>
<short-bech32 :address="user.address || ''" />
<short-bech32 v-if="user.signedIn" :address="user.address || ''" />
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
<div class="tabs">
<div
v-for="tab in tabs"
Expand Down
21 changes: 2 additions & 19 deletions app/src/renderer/components/common/ToolBar.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<template>
<div class="tool-bar">
<a
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
v-tooltip.bottom="'Back'"
:disabled="user.history.length === 0"
class="back"
@click="back"
>
<i class="material-icons">arrow_back</i>
</a>
<a
v-tooltip.bottom="'Refresh'"
v-if="!!refresh"
Expand All @@ -32,7 +24,7 @@
</a>
<router-link
v-tooltip.bottom="'Preferences'"
v-if="config.devMode"
v-if="config.devMode && user.signedIn"
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
id="settings"
to="/preferences"
>
Expand All @@ -59,7 +51,7 @@ export default {
}
},
computed: {
...mapGetters([`user`, `lastPage`, `config`]),
...mapGetters([`user`, `config`]),
searchEnabled() {
return !!this.searching
},
Expand All @@ -71,15 +63,6 @@ export default {
}
},
methods: {
...mapMutations([`pauseHistory`, `popHistory`]),
back() {
if (!this.lastPage) return
this.pauseHistory(true)
this.$router.push(this.lastPage, () => {
this.popHistory()
this.pauseHistory(false)
})
},
enableModalHelp() {
this.$store.commit(`setModalHelp`, true)
},
Expand Down
14 changes: 12 additions & 2 deletions app/src/renderer/components/governance/PageGovernance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ export default {
]
}),
computed: {
...mapGetters([`proposals`, `filters`, `depositDenom`, `connected`]),
...mapGetters([
`proposals`,
`filters`,
`depositDenom`,
`connected`,
`user`
]),
proposalList() {
return Object.values(this.proposals.proposals)
}
Expand All @@ -61,7 +67,11 @@ export default {
},
methods: {
onPropose() {
this.$refs.modalPropose.open()
if (this.user.signedIn) {
this.$refs.modalPropose.open()
} else {
this.$store.commit(`setModalSession`, true)
}
}
}
}
Expand Down
25 changes: 17 additions & 8 deletions app/src/renderer/components/governance/PageProposal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ export default {
`connected`,
`wallet`,
`votes`,
`config`
`config`,
`user`
]),
proposal() {
return this.proposals.proposals[this.proposalId]
Expand Down Expand Up @@ -250,15 +251,23 @@ export default {
},
methods: {
async onVote() {
this.$refs.modalVote.open()
// The error is already handled with notifyError in votes.js
await this.$store.dispatch(`getProposalVotes`, this.proposalId)
this.lastVote =
this.votes[this.proposalId] &&
this.votes[this.proposalId].find(e => e.voter === this.wallet.address)
if (this.user.signedIn) {
this.$refs.modalVote.open()
// The error is already handled with notifyError in votes.js
await this.$store.dispatch(`getProposalVotes`, this.proposalId)
this.lastVote =
this.votes[this.proposalId] &&
this.votes[this.proposalId].find(e => e.voter === this.wallet.address)
} else {
this.$store.commit(`setModalSession`, true)
}
},
onDeposit() {
this.$refs.modalDeposit.open()
if (this.user.signedIn) {
this.$refs.modalDeposit.open()
} else {
this.$store.commit(`setModalSession`, true)
}
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions app/src/renderer/components/staking/PageStaking.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ export default {
data: () => ({
query: ``,
tabs: [
{
displayName: `My Delegations`,
pathName: `My Delegations`
},
{
displayName: `Validators`,
pathName: `Validators`
Expand All @@ -34,7 +30,15 @@ export default {
]
}),
computed: {
...mapGetters([`connected`, `delegates`, `filters`])
...mapGetters([`connected`, `delegates`, `filters`, `user`])
},
mounted() {
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
if (this.user.signedIn) {
this.tabs.unshift({
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
displayName: `My Delegations`,
pathName: `My Delegations`
})
}
},
methods: {
...mapActions([`updateDelegates`])
Expand Down
25 changes: 17 additions & 8 deletions app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export default {
`config`,
`keybase`,
`liquidAtoms`,
`user`,
`wallet`,
`connected`
]),
Expand Down Expand Up @@ -315,19 +316,27 @@ export default {
this.showCannotModal = false
},
onDelegation() {
this.action = `delegate`
if (this.liquidAtoms > 0) {
this.$refs.delegationModal.open()
if (this.user.signedIn) {
this.action = `delegate`
if (this.liquidAtoms > 0) {
this.$refs.delegationModal.open()
} else {
this.showCannotModal = true
}
} else {
this.showCannotModal = true
this.$store.commit(`setModalSession`, true)
}
},
onUndelegation() {
this.action = `undelegate`
if (this.myBond.isGreaterThan(0)) {
this.$refs.undelegationModal.open()
if (this.user.signedIn) {
this.action = `undelegate`
if (this.myBond.isGreaterThan(0)) {
this.$refs.undelegationModal.open()
} else {
this.showCannotModal = true
}
} else {
this.showCannotModal = true
this.$store.commit(`setModalSession`, true)
}
},
delegationTargetOptions() {
Expand Down
3 changes: 0 additions & 3 deletions app/src/renderer/components/staking/TableValidators.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ export default {
async mounted() {
Mousetrap.bind([`command+f`, `ctrl+f`], () => this.setSearch(true))
Mousetrap.bind(`esc`, () => this.setSearch(false))

// XXX temporary because querying the shares shows old shares after bonding
// this.updateDelegates()
},
methods: {
updateDelegates() {
Expand Down
7 changes: 4 additions & 3 deletions app/src/renderer/vuex/modules/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function({ node }) {
}, 1000)
}
},
async rpcSubscribe({ commit, dispatch }) {
async rpcSubscribe({ commit, dispatch, rootState }) {
const { node } = state.externals
if (state.stopConnecting) return

Expand Down Expand Up @@ -101,8 +101,9 @@ export default function({ node }) {
dispatch(`setLastHeader`, header)
}
)

dispatch(`walletSubscribe`)
if (rootState.user.signedIn) {
dispatch(`walletSubscribe`)
}
dispatch(`checkNodeHalted`)
dispatch(`pollRPCConnection`)
},
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/delegation.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export default ({ node }) => {
}
}
const actions = {
reconnected({ state, dispatch }) {
if (state.loading) {
reconnected({ state, dispatch, rootState }) {
if (state.loading && rootState.user.signedIn) {
dispatch(`getBondedDelegates`)
}
},
Expand Down
5 changes: 3 additions & 2 deletions app/src/renderer/vuex/modules/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ export default ({ node }) => {
// clear previous account state
rootState.transactions = JSON.parse(JSON.stringify(emptyState))
},
async reconnected({ state, dispatch }) {
if (state.loading) {
async reconnected({ state, dispatch, rootState }) {
// TODO: remove signedIn check when we support the option for setting a custom address for txs page
if (state.loading && rootState.user.signedIn) {
await dispatch(`getAllTxs`)
}
},
Expand Down
19 changes: 7 additions & 12 deletions app/src/renderer/vuex/modules/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export default ({}) => {
}

const mutations = {
setSignIn(state, hasSignedIn) {
state.signedIn = hasSignedIn
},
setAccounts(state, accounts) {
state.accounts = accounts
},
Expand All @@ -62,15 +65,9 @@ export default ({}) => {
},
async showInitialScreen({ state, dispatch, commit }) {
dispatch(`resetSessionData`)

await dispatch(`loadAccounts`)
const exists = state.accounts.length > 0
const screen = exists ? `sign-in` : `welcome`
commit(`setModalSessionState`, screen)

state.externals.track(`pageview`, {
dl: `/session/` + screen
})
commit(`setModalSessionState`, `welcome`)
state.externals.track(`pageview`, { dl: `/` })
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the thinking here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the main page is not longer /session/welcome

},
async loadAccounts({ commit, state }) {
state.loading = true
Expand Down Expand Up @@ -105,8 +102,7 @@ export default ({}) => {
},
async signIn({ state, commit, dispatch }, { account }) {
state.account = account
state.signedIn = true

commit(`setSignIn`, true)
const keys = await state.externals.loadKeys()
const { address } = keys.find(({ name }) => name === account)

Expand All @@ -121,8 +117,7 @@ export default ({}) => {
},
signOut({ state, commit, dispatch }) {
state.account = null
state.signedIn = false

commit(`setSignIn`, false)
commit(`setModalSession`, true)
dispatch(`showInitialScreen`)
},
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default ({ node }) => {
}

const actions = {
reconnected({ state, dispatch }) {
if (state.loading && state.address) {
reconnected({ state, dispatch, rootState }) {
if (state.loading && state.address && rootState.user.signedIn) {
dispatch(`queryWalletBalances`)
}
},
Expand Down
Loading