Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion src/components/WelcomeBack/WalletList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<script>
import { mapState, mapActions, mapMutations } from 'vuex'
import { localStorageWrapper } from '@/main'
import Select from '@/components/Select'
import Card from '@/components/card/Card'

Expand All @@ -65,11 +66,13 @@ export default {
walletId: state => {
return state.wallet.walletId
},
getWalletIndex: state => state.wallet.localStorage.getWalletIndex(),
sessionId: state => state.wallet.sessionId,
unlockWalletError: state => state.wallet.errors.unlockWallet,
wallets: state => state.wallet.walletInfos,
}),
getWalletIndex() {
return localStorageWrapper.getWalletIndex()
},
lastWalletOpen() {
return this.getWalletIndex || 0
},
Expand Down
8 changes: 8 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Vue from 'vue'
import IdleVue from 'idle-vue'
import { WalletApi, LocalStorageApi } from './api'
import App from './App.vue'
import router from './router'
import store from './store'
import ProcessWalletEvent from './services/ProcessWalletEvent'
import i18n from '@/plugins/i18n'
import './plugins/element.js'
import './fontAwesome'
Expand All @@ -11,6 +13,10 @@ import '@/ipcHandlers'
// TODO: delete
declare let window: any

const api = new WalletApi()
const localStorageWrapper = new LocalStorageApi()
const eventProcessor = new ProcessWalletEvent()

Vue.config.productionTip = false

const eventsHub = new Vue()
Expand All @@ -32,3 +38,5 @@ function runApp() {

window.vm = vm
}

export { api, localStorageWrapper, eventProcessor }
15 changes: 8 additions & 7 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Vue from 'vue'
import Router from 'vue-router'
import { api } from './main'
import Community from '@/components/Community.vue'
import DataRequest from '@/components/DataRequest.vue'
import Editor from '@/components/Editor.vue'
Expand Down Expand Up @@ -33,7 +34,7 @@ import { SETTINGS_SECTIONS } from '@/constants'

Vue.use(Router)
function redirectOnReload(to, from, next) {
if (store.state.wallet.api.client.ws.ready) {
if (api.client.ws.ready) {
next()
} else {
next('/')
Expand Down Expand Up @@ -71,7 +72,7 @@ export default new Router({
name: 'main',
component: Main,
beforeEnter: async (to, from, next) => {
const isReady = store.state.wallet.api.client.ws.ready
const isReady = api.client.ws.ready

if (isReady) {
await store.dispatch('getWalletInfos')
Expand All @@ -86,9 +87,9 @@ export default new Router({
}
// when the computer is blocked the client closes but it should not redirect to
// wallet not found if the wallet is not closed
store.state.wallet.api.client.ws.on('close', () => {
api.client.ws.on('close', () => {
setTimeout(() => {
if (!store.state.wallet.api.client.ws.ready) {
if (!api.client.ws.ready) {
next('/wallet-not-found')
}
}, 1000)
Expand All @@ -100,7 +101,7 @@ export default new Router({
next('/wallet-not-found')
}
}, 3000)
store.state.wallet.api.client.ws.on('open', async () => {
api.client.ws.on('open', async () => {
const polling = setInterval(async () => {
error = false
clearInterval(polling)
Expand Down Expand Up @@ -171,7 +172,7 @@ export default new Router({
path: '/wallet-not-found',
name: 'runWalletAlert',
beforeEnter: async (to, from, next) => {
if (store.state.wallet.api.client.ws.ready) {
if (api.client.ws.ready) {
await store.dispatch('getWalletInfos')
const walletInfos = store.state.wallet.walletInfos
if (walletInfos && walletInfos.length > 0) {
Expand All @@ -187,7 +188,7 @@ export default new Router({
}
}, 2000)

store.state.wallet.api.client.ws.on('open', async () => {
api.client.ws.on('open', async () => {
error = false
await store.dispatch('getWalletInfos')
const polling = setInterval(() => {
Expand Down
7 changes: 3 additions & 4 deletions src/store/uiInteractions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue'
import { LocalStorageApi } from '@/api'
import { localStorageWrapper } from '@/main'

export default {
state: {
Expand All @@ -9,7 +9,6 @@ export default {
setupMessage: 'Updating wallet backend',
setupProgress: 0,
sessionExpired: false,
localStorage: new LocalStorageApi(),
isResyncConfirmationVisible: false,
isWalletDescriptionVisible: false,
isRenameWalletConfirmationVisible: false,
Expand Down Expand Up @@ -84,8 +83,8 @@ export default {
notify(context, payload) {
Vue.prototype.$notify(payload)
},
saveShowModalAgain(context, val) {
context.state.localStorage.setSkipSessionExpirationInfo(val)
saveShowModalAgain(_context, val) {
localStorageWrapper.setSkipSessionExpirationInfo(val)
},
},
}
Loading