Skip to content

Commit

Permalink
Fix defect for legacy wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur325 committed Aug 5, 2024
1 parent f3425fe commit 526dd18
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
21 changes: 21 additions & 0 deletions src/views/Tools/LegacyWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 526dd18

Please sign in to comment.