mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 10:57:04 +00:00
Tweak data loading
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {displayRelayUrl, GROUP_META} from "@welshman/util"
|
||||
import {displayRelayUrl} from "@welshman/util"
|
||||
import {fly} from "@lib/transition"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
@@ -22,7 +22,6 @@
|
||||
deriveOtherRooms,
|
||||
} from "@app/state"
|
||||
import {notifications} from "@app/notifications"
|
||||
import {pullConservatively} from "@app/requests"
|
||||
import {pushModal} from "@app/modal"
|
||||
import {makeSpacePath} from "@app/routes"
|
||||
|
||||
@@ -66,7 +65,6 @@
|
||||
|
||||
onMount(() => {
|
||||
replaceState = Boolean(element?.closest(".drawer"))
|
||||
pullConservatively({relays: [url], filters: [{kinds: [GROUP_META]}]})
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import {onMount} from "svelte"
|
||||
import type {Snippet} from "svelte"
|
||||
import {groupBy, uniq, uniqBy, batch} from "@welshman/lib"
|
||||
import {REACTION, getTag, REPORT, DELETE} from "@welshman/util"
|
||||
import {REACTION, getReplyFilters, getTag, REPORT, DELETE} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {deriveEvents} from "@welshman/store"
|
||||
import {load} from "@welshman/net"
|
||||
@@ -58,11 +58,11 @@
|
||||
load({
|
||||
relays: [url],
|
||||
signal: controller.signal,
|
||||
filters: [{kinds: [REACTION, REPORT, DELETE], "#e": [event.id]}],
|
||||
filters: getReplyFilters([event], {kinds: [REACTION, REPORT, DELETE]}),
|
||||
onEvent: batch(300, (events: TrustedEvent[]) => {
|
||||
load({
|
||||
relays: [url],
|
||||
filters: [{kinds: [DELETE], "#e": events.map(e => e.id)}],
|
||||
filters: getReplyFilters(events, {kinds: [DELETE]}),
|
||||
})
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {sleep, identity, nthEq} from "@welshman/lib"
|
||||
import {load} from "@welshman/net"
|
||||
import {request} from "@welshman/net"
|
||||
import {displayRelayUrl, AUTH_INVITE} from "@welshman/util"
|
||||
import {slide} from "@lib/transition"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
@@ -29,7 +29,11 @@
|
||||
|
||||
onMount(async () => {
|
||||
const [[event]] = await Promise.all([
|
||||
load({filters: [{kinds: [AUTH_INVITE]}], relays: [url]}),
|
||||
request({
|
||||
relays: [url],
|
||||
autoClose: true,
|
||||
filters: [{kinds: [AUTH_INVITE]}],
|
||||
}),
|
||||
sleep(2000),
|
||||
])
|
||||
|
||||
|
||||
@@ -348,9 +348,7 @@ export const listenForNotifications = () => {
|
||||
relays: [url],
|
||||
filters: [
|
||||
{kinds: [THREAD], limit: 1},
|
||||
{kinds: [EVENT_TIME], limit: 1},
|
||||
{kinds: [COMMENT], "#K": [String(THREAD)], limit: 1},
|
||||
{kinds: [COMMENT], "#K": [String(EVENT_TIME)], limit: 1},
|
||||
...rooms.map(room => ({kinds: [MESSAGE], "#h": [room], limit: 1})),
|
||||
],
|
||||
})
|
||||
@@ -359,8 +357,8 @@ export const listenForNotifications = () => {
|
||||
signal: controller.signal,
|
||||
relays: [url],
|
||||
filters: [
|
||||
{kinds: [THREAD, EVENT_TIME], since: now()},
|
||||
{kinds: [COMMENT], "#K": [String(THREAD), String(EVENT_TIME)], since: now()},
|
||||
{kinds: [THREAD], since: now()},
|
||||
{kinds: [COMMENT], "#K": [String(THREAD)], since: now()},
|
||||
...rooms.map(room => ({kinds: [MESSAGE], "#h": [room], since: now()})),
|
||||
],
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {Address, getIdFilters, getTagValue} from "@welshman/util"
|
||||
import {request} from "@welshman/net"
|
||||
import {load} from "@welshman/net"
|
||||
import {page} from "$app/stores"
|
||||
import {goto} from "$app/navigation"
|
||||
import {scrollToEvent} from "@lib/html"
|
||||
@@ -21,10 +21,9 @@
|
||||
|
||||
let found = false
|
||||
|
||||
request({
|
||||
autoClose: true,
|
||||
filters: getIdFilters([type === "nevent" ? data.id : Address.fromNaddr(bech32).toString()]),
|
||||
load({
|
||||
relays: data.relays,
|
||||
filters: getIdFilters([type === "nevent" ? data.id : Address.fromNaddr(bech32).toString()]),
|
||||
onEvent: (event: TrustedEvent) => {
|
||||
found = true
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {page} from "$app/stores"
|
||||
import {ago, MONTH} from "@welshman/lib"
|
||||
import {GROUPS, THREAD, COMMENT, MESSAGE} from "@welshman/util"
|
||||
import {ago, WEEK} from "@welshman/lib"
|
||||
import {GROUP_META, EVENT_TIME, GROUPS, THREAD, COMMENT, MESSAGE} from "@welshman/util"
|
||||
import {request} from "@welshman/net"
|
||||
import Page from "@lib/components/Page.svelte"
|
||||
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
||||
@@ -52,21 +52,22 @@
|
||||
checkConnection()
|
||||
|
||||
const relays = [url]
|
||||
const since = ago(MONTH)
|
||||
const since = ago(WEEK)
|
||||
const controller = new AbortController()
|
||||
|
||||
// Load groups, threads, comments, and recent messages for user rooms to help with a quick page transition
|
||||
// Load group meta, threads, calendar events, comments, and recent messages
|
||||
// for user rooms to help with a quick page transition
|
||||
pullConservatively({
|
||||
relays,
|
||||
filters: [
|
||||
{kinds: [THREAD], since},
|
||||
{kinds: [COMMENT], "#K": [String(THREAD)], since},
|
||||
...rooms.map(r => ({kinds: [MESSAGE], "#h": [r], since})),
|
||||
{kinds: [GROUP_META]},
|
||||
{kinds: [THREAD, EVENT_TIME], since},
|
||||
{kinds: [COMMENT], "#K": [String(THREAD), String(EVENT_TIME)], since},
|
||||
...rooms.map(room => ({kinds: [MESSAGE], "#h": [room], since})),
|
||||
],
|
||||
})
|
||||
|
||||
// Completely refresh our groups list and listen for new ones
|
||||
const controller = new AbortController()
|
||||
|
||||
request({relays, filters: [{kinds: [GROUPS]}], signal: controller.signal})
|
||||
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user