Skip to content

Commit

Permalink
Set stored balance in localStorage to avoid showing zero balance whil…
Browse files Browse the repository at this point in the history
…e loading on start
  • Loading branch information
n9lsjr committed Feb 13, 2024
1 parent 2b2a3aa commit 4bd2d7f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib/stores/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const wallet = writable({
addresses: [],
preparedTransaction: undefined,
file: false,
path: false
path: false,
started: false
})

export const transactions = writable({
Expand Down
2 changes: 2 additions & 0 deletions src/routes/auth/create-wallet/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
await goto('/auth/backup-wallet');
}
}
$wallet.started = true
};
const openFromFile = () => {
Expand Down
7 changes: 6 additions & 1 deletion src/routes/auth/login-wallet/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
await goto('/wallet/dashboard');
password = '';
loading = false;
//Set stored balance to avoid showing zero balance while loading
$wallet.balance = [localStorage.getItem('balance'), 0] ?? [0, 0];
$wallet.started = true;
});
});
Expand Down Expand Up @@ -120,7 +123,9 @@
<div>
<p style="opacity: 50%">v1.0.0</p>
<p>{$wallet.currentWallet}.wallet</p>
<p class="import" on:click={() => openFromFile()}>Open another wallet</p>
{#if !$wallet.started}
<p class="import" on:click={() => openFromFile()}>Open another wallet</p>
{/if}
<input
bind:this={fileList}
Expand Down
1 change: 1 addition & 0 deletions src/routes/wallet/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
$node.walletBlockCount = data.walletBlockCount;
$wallet.balance = data.balance;
$user.idleTime = data.idle ?? 0;
localStorage.setItem('balance', data.balance[0]);
});
window.api.receive('node-status', (res) => {
Expand Down

0 comments on commit 4bd2d7f

Please sign in to comment.