-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
109 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
explorer/src/lib/components/transactions-card/TransactionsCard.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.transactions-card__table, | ||
.transactions-card__list { | ||
max-height: 600px; | ||
overflow-y: auto; | ||
} |
77 changes: 77 additions & 0 deletions
77
explorer/src/lib/components/transactions-card/TransactionsCard.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<svelte:options immutable={true} /> | ||
|
||
<script> | ||
import { | ||
DataCard, | ||
TransactionsList, | ||
TransactionsTable, | ||
} from "$lib/components"; | ||
import "./TransactionsCard.css"; | ||
/** @type {Transaction[] | null}*/ | ||
export let txs; | ||
/** @type {Error | null}*/ | ||
export let error; | ||
/** @type {Boolean} */ | ||
export let loading; | ||
const ITEMS_TO_DISPLAY = 15; | ||
let itemsToDisplay = ITEMS_TO_DISPLAY; | ||
/** @type {number} */ | ||
let clientWidth; | ||
/** @type {Transaction[]}*/ | ||
let displayedBlocks; | ||
/** @type {Boolean}*/ | ||
let disabledLoading = false; | ||
const loadMoreItems = () => { | ||
if (txs && itemsToDisplay < txs.length) { | ||
itemsToDisplay += ITEMS_TO_DISPLAY; | ||
} | ||
}; | ||
$: displayedBlocks = txs ? txs.slice(0, itemsToDisplay) : []; | ||
$: { | ||
if (txs && itemsToDisplay >= txs.length) { | ||
disabledLoading = true; | ||
} else if (loading && txs === null) { | ||
disabledLoading = true; | ||
} else { | ||
disabledLoading = false; | ||
} | ||
} | ||
</script> | ||
|
||
<svelte:window bind:outerWidth={clientWidth} /> | ||
<DataCard | ||
on:retry | ||
data={txs} | ||
{error} | ||
{loading} | ||
title="Transactions" | ||
headerButtonDetails={{ | ||
action: () => loadMoreItems(), | ||
disabled: disabledLoading, | ||
label: "Show More", | ||
}} | ||
> | ||
{#if clientWidth > 768} | ||
<TransactionsTable | ||
data={displayedBlocks} | ||
className="transactions-card__table" | ||
/> | ||
{:else} | ||
<div class="transactions-card__list"> | ||
{#each displayedBlocks as tx (tx.txid)} | ||
<TransactionsList data={tx} /> | ||
{/each} | ||
</div> | ||
{/if} | ||
</DataCard> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
<script> | ||
import { TransactionsCard } from "$lib/components"; | ||
import { duskAPI } from "$lib/services"; | ||
import { appStore } from "$lib/stores"; | ||
import { createPollingDataStore } from "$lib/dusk/svelte-stores"; | ||
import { onNetworkChange } from "$lib/lifecyles"; | ||
const pollingDataStore = createPollingDataStore( | ||
duskAPI.getTransactions, | ||
$appStore.fetchInterval | ||
); | ||
onNetworkChange((network) => { | ||
pollingDataStore.stop(); | ||
pollingDataStore.start(network); | ||
}); | ||
$: ({ data, error, isLoading } = $pollingDataStore); | ||
</script> | ||
|
||
<section class="transactions"> | ||
<div>All Transactions</div> | ||
<TransactionsCard | ||
on:retry={pollingDataStore.start} | ||
txs={data} | ||
{error} | ||
loading={isLoading} | ||
/> | ||
</section> |
14 changes: 0 additions & 14 deletions
14
explorer/src/routes/transactions/__tests__/__snapshots__/page.spec.js.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.