From b4c643c27c43836cf8ec44f2dd580e6e1e033839 Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Mon, 7 Jan 2019 23:20:07 +0000 Subject: [PATCH] Fix bug with much wallet option! --- package.json | 2 +- src/main/config.js | 6 ++++-- .../components/Landing/LandingPage.vue | 8 ++------ .../Wizards/CreateWalletOptions.vue | 19 ++++--------------- src/renderer/store/index.js | 7 ++++++- 5 files changed, 17 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index eaefa3a..26ba72d 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,7 @@ "vue-template-compiler": "^2.4.2", "vuex": "^3.0.1", "webpack": "^3.5.2", - "webpack-dev-server": ">=3.1.11", + "webpack-dev-server": "^2.11.3", "webpack-hot-middleware": "^2.18.2" } } diff --git a/src/main/config.js b/src/main/config.js index 584956d..47915f0 100644 --- a/src/main/config.js +++ b/src/main/config.js @@ -70,7 +70,9 @@ export class Config { } const name = path.split('/').pop(); - this.data.wallets.push({ name, path }); - this.save(); + if (!this.data.wallets.find(wallet => wallet.name === name && wallet.path === path)) { + this.data.wallets.push({ name, path }); + this.save(); + } } } diff --git a/src/renderer/components/Landing/LandingPage.vue b/src/renderer/components/Landing/LandingPage.vue index 4f539fd..4b87392 100644 --- a/src/renderer/components/Landing/LandingPage.vue +++ b/src/renderer/components/Landing/LandingPage.vue @@ -22,7 +22,7 @@ @@ -123,8 +123,7 @@ }); }, openLastWallet(event){ - const selectedWallet = this.cfg_wallets.find(i => i.name === event.currentTarget.text); - this.$store.commit('addWalletPath', selectedWallet.path); + this.$store.commit('addWalletPath', event.target.dataset.path); this.$store.commit('showPassword', { 'message': 'Enter wallet password' }); @@ -194,9 +193,6 @@ }, cfg_wallets(){ return this.$store.getters.cfg.wallets; - }, - cfg_wallet_names(){ - return this.$store.getters.cfg.wallets.map(i => i.name); } } } diff --git a/src/renderer/components/Wizards/CreateWalletOptions.vue b/src/renderer/components/Wizards/CreateWalletOptions.vue index 3448b0b..6bd8825 100644 --- a/src/renderer/components/Wizards/CreateWalletOptions.vue +++ b/src/renderer/components/Wizards/CreateWalletOptions.vue @@ -67,20 +67,12 @@ this.create_wallet(wallet_name, wallet_pass); } }, - wallet_exists (name) { - return !!this.wallets.find(i => i.name === name); - }, create_wallet (name, password) { - if (this.wallet_exists(name)) { - console.log('Wallet exists!') - // @TODO check if wallet with same name exists no matter the path - } else { - this.clearMatrixMsg(); - this.showMatrixMsg('GENERATING NEW WALLET'); + this.clearMatrixMsg(); + this.showMatrixMsg('GENERATING NEW WALLET'); - this.$store.commit('appState', "create_wallet"); - ipcRenderer.send('rpc_create_wallet', {name: name, password: password}) - } + this.$store.commit('appState', "create_wallet"); + ipcRenderer.send('rpc_create_wallet', {name: name, password: password}) }, showMatrixMsg(msg){ let obj = jQuery('.teh_matrix span.centered'); @@ -187,9 +179,6 @@ }, walletCreating(){ return this.$store.state.wallet_creating; - }, - wallets() { - return this.$store.getters.cfg.wallets; } } } diff --git a/src/renderer/store/index.js b/src/renderer/store/index.js index 64ca8fb..c771750 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -95,9 +95,14 @@ export default new Vuex.Store({ state.height_from = data.from; state.height_to = data.to; }, - addWallet({wallet}, data){ + addWallet({cfg, wallet}, data){ if(data.hasOwnProperty('wallet_path')){ wallet.path = data.wallet_path; + + const name = data.wallet_path.split('/').pop(); + if (!cfg.wallets.find(wallet => wallet.name === name && wallet.path === data.wallet_path)) { + cfg.wallets.push({ name, path: data.wallet_path }); + } } if(data.hasOwnProperty('txs')){ -- 2.25.1