From b5b634496817f830464eed76d96c9156f4da3f69 Mon Sep 17 00:00:00 2001 From: bomb-on <0nada0@gmail.com> Date: Wed, 5 Dec 2018 10:38:54 +0000 Subject: [PATCH] So much wallets --- src/main/config.js | 5 +++-- .../components/Landing/LandingPage.vue | 21 +++++++------------ .../Wizards/CreateWalletOptions.vue | 19 +++++++++++++---- src/renderer/store/index.js | 6 +++++- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/main/config.js b/src/main/config.js index d691ecc..584956d 100644 --- a/src/main/config.js +++ b/src/main/config.js @@ -31,7 +31,7 @@ export class Config { {"address": "node.wownero.com:34568", "location": "Montreal, Canada", "region": "US"}, {"address": "localhost:34568", 'location': "", "region": "*"} ], - "wallet_path": "" + "wallets": [] }); fs.writeFileSync(this._path_cfg, JSON.stringify(data)); @@ -69,7 +69,8 @@ export class Config { return; } - this.data.wallet_path = path; + const name = path.split('/').pop(); + 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 c9f1507..0221baa 100644 --- a/src/renderer/components/Landing/LandingPage.vue +++ b/src/renderer/components/Landing/LandingPage.vue @@ -22,7 +22,7 @@ @@ -118,13 +118,9 @@ } }); }, - openLastWallet(){ - if(!this.cfg_wallet_path || this.cfg_wallet_path === ''){ - alert('Invalid wallet path?!'); - return; - } - - this.$store.commit('addWalletPath', this.cfg_wallet_path); + openLastWallet(event){ + const selectedWallet = this.cfg_wallets.find(i => i.name === event.currentTarget.text); + this.$store.commit('addWalletPath', selectedWallet.path); this.$store.commit('showPassword', { 'message': 'Enter wallet password' }); @@ -192,12 +188,11 @@ selected_node(){ return this.$store.getters.cfg.node; }, - cfg_wallet_path(){ - return this.$store.getters.cfg.wallet_path; + cfg_wallets(){ + return this.$store.getters.cfg.wallets; }, - cfg_wallet_path_name(){ - let path = require("path"); - return path.basename(this.cfg_wallet_path); + 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 7a34d78..3448b0b 100644 --- a/src/renderer/components/Wizards/CreateWalletOptions.vue +++ b/src/renderer/components/Wizards/CreateWalletOptions.vue @@ -67,12 +67,20 @@ this.create_wallet(wallet_name, wallet_pass); } }, + wallet_exists (name) { + return !!this.wallets.find(i => i.name === name); + }, create_wallet (name, password) { - this.clearMatrixMsg(); - this.showMatrixMsg('GENERATING NEW WALLET') + 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.$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'); @@ -179,6 +187,9 @@ }, 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 41b17ac..64ca8fb 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -11,7 +11,7 @@ export default new Vuex.Store({ cfg: { "node": "", "nodes": [], - "wallet_path": "" + "wallets": [] }, created_wallet: {}, // only used when creating wallets appState: "", // not really used @@ -69,6 +69,10 @@ export default new Vuex.Store({ if(data.hasOwnProperty('wallet_path')){ cfg.wallet_path = data.wallet_path; } + + if(data.hasOwnProperty('wallets')){ + cfg.wallets = data.wallets; + } }, appState(state, data){ state.appState = data;