Skip to content

Commit

Permalink
Only watch in auto mode
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Mar 29, 2024
1 parent c200231 commit 0577b6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib/components/documents/ResultsList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
count = r.count;
next = r.next;
loading = false;
watch();
if (auto) watch();
}
function watch() {
Expand Down Expand Up @@ -91,9 +91,13 @@
{/each}
<div class="end" bind:this={end}>
{#if next}
<Button disabled={loading} on:click={(e) => load(new URL(next))}
>Load more</Button
>
<Button disabled={loading} on:click={(e) => load(new URL(next))}>
{#if loading}
Loading ...
{:else}
Load more
{/if}
</Button>
{/if}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@
<Story name="Empty">
<div style="width: 36rem"><ResultsList /></div>
</Story>

<Story name="Infinite">
<div style="width: 36rem"><ResultsList {results} {count} {next} auto /></div>
</Story>

0 comments on commit 0577b6f

Please sign in to comment.