Listen for new messages in channel

This commit is contained in:
Jon Staab
2024-08-26 14:39:00 -07:00
parent 51b0c69513
commit 644c32dd09
4 changed files with 18 additions and 7 deletions
+13 -3
View File
@@ -8,15 +8,16 @@
</script>
<script lang="ts">
import {sortBy} from "@welshman/lib"
import type {TrustedEvent} from "@welshman/util"
import {onMount} from 'svelte'
import {page} from "$app/stores"
import {sortBy, now} from "@welshman/lib"
import type {TrustedEvent} from "@welshman/util"
import {formatTimestampAsDate} from "@lib/util"
import Icon from "@lib/components/Icon.svelte"
import Spinner from "@lib/components/Spinner.svelte"
import GroupNote from "@app/components/GroupNote.svelte"
import GroupCompose from "@app/components/GroupCompose.svelte"
import {deriveGroupChat} from "@app/state"
import {subscribe, deriveGroupChat, userRelayUrlsByNom} from "@app/state"
const {nom} = $page.params
const chat = deriveGroupChat(nom)
@@ -57,6 +58,15 @@
setTimeout(() => {
loading = false
}, 3000)
onMount(() => {
const sub = subscribe({
filters: [{'#h': [nom], since: now() - 30}],
relays: $userRelayUrlsByNom.get(nom)!,
})
return () => sub.close()
})
</script>
<div class="relative flex h-screen flex-col">