Simplify reactive code

This commit is contained in:
Alexis Sellier
2021-05-03 00:40:58 +02:00
parent 8819c8c6f7
commit 451ae1fdc3
2 changed files with 9 additions and 11 deletions
+4 -6
View File
@@ -8,9 +8,7 @@
let walletUnavailable = !window.ethereum;
const connecting = derived(session, ($s) => {
return $s.connection === Connection.Connecting;
});
$: connecting = $session.connection === Connection.Connecting;
</script>
<style>
@@ -20,10 +18,10 @@
on:click={connectWallet}
{style}
class="connect {className}"
disabled={$connecting || walletUnavailable}
data-waiting={$connecting || null}
disabled={connecting || walletUnavailable}
data-waiting={connecting || null}
>
{#if $connecting}
{#if connecting}
Connecting...
{:else}
{caption}
+5 -5
View File
@@ -13,8 +13,8 @@
let sessionButton = null;
let sessionButtonHover = false;
const address = derived(session, $s => { return $s.address });
const tokenBalance = derived(session, $s => { return $s.tokenBalance });
$: address = $session.address;
$: tokenBalance = $session.tokenBalance;
</script>
<style>
@@ -82,9 +82,9 @@
<a use:link href="/vesting/">Vesting</a>
</span>
{#if $address}
{#if address}
<span class="balance">
{formatBalance($tokenBalance)} <strong>RAD</strong>
{formatBalance(tokenBalance)} <strong>RAD</strong>
</span>
<button class="address outline small" bind:this={sessionButton}
@@ -95,7 +95,7 @@
{#if sessionButtonHover}
Disconnect
{:else}
{formatAddress($address)}
{formatAddress(address)}
{/if}
</button>
{:else}