Improve loading indicator in channels

This commit is contained in:
Jon Staab
2024-12-11 10:31:39 -08:00
parent 72ced31625
commit a378ecbad4
2 changed files with 8 additions and 13 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import {slide, fade} from "svelte/transition" import {slide, fade} from "svelte/transition"
export let loading export let loading = false
</script> </script>
<span class="flex min-h-10 items-center"> <span class="flex min-h-10 items-center">
+7 -12
View File
@@ -91,7 +91,7 @@
}) })
let limit = 30 let limit = 30
let loading = true let loading = sleep(5000)
let unsub: () => void let unsub: () => void
let element: HTMLElement let element: HTMLElement
let scroller: Scroller let scroller: Scroller
@@ -135,6 +135,7 @@
threshold: 3000, threshold: 3000,
onScroll: () => { onScroll: () => {
limit += 30 limit += 30
loading = sleep(5000)
}, },
}) })
@@ -146,10 +147,6 @@
scroller?.stop() scroller?.stop()
unsub?.() unsub?.()
}) })
setTimeout(() => {
loading = false
}, 5000)
</script> </script>
<div class="relative flex h-full flex-col"> <div class="relative flex h-full flex-col">
@@ -190,13 +187,11 @@
{/if} {/if}
{/each} {/each}
<p class="flex h-10 items-center justify-center py-20"> <p class="flex h-10 items-center justify-center py-20">
<Spinner {loading}> {#await loading}
{#if loading} <Spinner loading>Looking for messages...</Spinner>
Looking for messages... {:then}
{:else} <Spinner>End of message history</Spinner>
End of message history {/await}
{/if}
</Spinner>
</p> </p>
</div> </div>
<ChannelCompose bind:editor {content} {onSubmit} /> <ChannelCompose bind:editor {content} {onSubmit} />