From 526dd18755cced2b567adb6be102c87a2b323fec Mon Sep 17 00:00:00 2001 From: "Jain, Ankur" Date: Mon, 5 Aug 2024 14:29:38 -0400 Subject: [PATCH] Fix defect for legacy wallet --- package-lock.json | 2 +- package.json | 2 +- src/views/Tools/LegacyWallet.vue | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 05edb66..57b97dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "dcl-ui", - "version": "1.0.14", + "version": "1.0.16", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 63f3956..510ff0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dcl-ui", - "version": "1.0.15", + "version": "1.0.16", "description": "A Vuejs based application for managing CSA Distributed Compliance Ledger", "author": "Comcast Inc.", "private": true, diff --git a/src/views/Tools/LegacyWallet.vue b/src/views/Tools/LegacyWallet.vue index ad8290f..1aa69c4 100644 --- a/src/views/Tools/LegacyWallet.vue +++ b/src/views/Tools/LegacyWallet.vue @@ -132,9 +132,30 @@ export default { const deleteWallet = () => { const index = wallets.value.findIndex(w => w.name === selectedWallet.value.name); if (index !== -1) { + // Check if the wallet being deleted is the lastWallet + const lastWalletName = localStorage.getItem('lastWallet'); + const isLastWallet = lastWalletName === selectedWallet.value.name; + + // Remove the wallet wallets.value.splice(index, 1); + + // Update wallets in localStorage localStorage.setItem('wallets', JSON.stringify(wallets.value)); + + // Update lastWallet if necessary + if (isLastWallet) { + if (wallets.value.length > 0) { + // If there are remaining wallets, set lastWallet to the next one (or the first one if we deleted the last wallet) + const nextIndex = index < wallets.value.length ? index : 0; + const nextWalletName = wallets.value[nextIndex].name; + localStorage.setItem('lastWallet', nextWalletName); + } else { + // If no wallets remain, remove lastWallet from localStorage + localStorage.removeItem('lastWallet'); + } + } } + deleteDialogVisible.value = false; selectedWallet.value = null; };