forked from coracle/flotilla
Improve loading a bit
This commit is contained in:
+3
-5
@@ -61,7 +61,7 @@ import {
|
|||||||
walkThunks,
|
walkThunks,
|
||||||
signer,
|
signer,
|
||||||
Router,
|
Router,
|
||||||
loadWithAsapMetaRelayUrls,
|
makeOutboxLoader,
|
||||||
routerContext,
|
routerContext,
|
||||||
appContext,
|
appContext,
|
||||||
} from "@welshman/app"
|
} from "@welshman/app"
|
||||||
@@ -332,8 +332,7 @@ export const {
|
|||||||
name: "settings",
|
name: "settings",
|
||||||
store: settings,
|
store: settings,
|
||||||
getKey: settings => settings.event.pubkey,
|
getKey: settings => settings.event.pubkey,
|
||||||
load: (pubkey: string, relays: string[]) =>
|
load: makeOutboxLoader([SETTINGS]),
|
||||||
loadWithAsapMetaRelayUrls(pubkey, relays, [{kinds: [SETTINGS], authors: [pubkey]}]),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Alerts
|
// Alerts
|
||||||
@@ -410,8 +409,7 @@ export const {
|
|||||||
name: "memberships",
|
name: "memberships",
|
||||||
store: memberships,
|
store: memberships,
|
||||||
getKey: list => list.event.pubkey,
|
getKey: list => list.event.pubkey,
|
||||||
load: (pubkey: string, relays: string[]) =>
|
load: makeOutboxLoader([GROUPS]),
|
||||||
loadWithAsapMetaRelayUrls(pubkey, relays, [{kinds: [GROUPS], authors: [pubkey]}]),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Chats
|
// Chats
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import {dev} from "$app/environment"
|
import {dev} from "$app/environment"
|
||||||
import {goto} from "$app/navigation"
|
import {goto} from "$app/navigation"
|
||||||
import {bytesToHex, hexToBytes} from "@noble/hashes/utils"
|
import {bytesToHex, hexToBytes} from "@noble/hashes/utils"
|
||||||
import {identity, sleep, defer, ago, WEEK, TaskQueue} from "@welshman/lib"
|
import {identity, memoize, sleep, defer, ago, WEEK, TaskQueue} from "@welshman/lib"
|
||||||
import type {TrustedEvent, StampedEvent} from "@welshman/util"
|
import type {TrustedEvent, StampedEvent} from "@welshman/util"
|
||||||
import {WRAP} from "@welshman/util"
|
import {WRAP} from "@welshman/util"
|
||||||
import {Nip46Broker, getPubkey, makeSecret} from "@welshman/signer"
|
import {Nip46Broker, getPubkey, makeSecret} from "@welshman/signer"
|
||||||
@@ -152,10 +152,12 @@
|
|||||||
// Listen for space data, populate space-based notifications
|
// Listen for space data, populate space-based notifications
|
||||||
let unsubSpaces: any
|
let unsubSpaces: any
|
||||||
|
|
||||||
userMembership.subscribe($membership => {
|
userMembership.subscribe(
|
||||||
unsubSpaces?.()
|
memoize($membership => {
|
||||||
unsubSpaces = listenForNotifications()
|
unsubSpaces?.()
|
||||||
})
|
unsubSpaces = listenForNotifications()
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
// Listen for chats, populate chat-based notifications
|
// Listen for chats, populate chat-based notifications
|
||||||
let chatsReq: any
|
let chatsReq: any
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import {ago, MONTH} from "@welshman/lib"
|
import {ago, MONTH} from "@welshman/lib"
|
||||||
import {GROUPS, THREAD, COMMENT, MESSAGE, DELETE} from "@welshman/util"
|
import {GROUPS, THREAD, COMMENT, MESSAGE} from "@welshman/util"
|
||||||
import {request, load} from "@welshman/net"
|
import {request} from "@welshman/net"
|
||||||
import Page from "@lib/components/Page.svelte"
|
import Page from "@lib/components/Page.svelte"
|
||||||
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
||||||
import MenuSpace from "@app/components/MenuSpace.svelte"
|
import MenuSpace from "@app/components/MenuSpace.svelte"
|
||||||
@@ -54,11 +54,7 @@
|
|||||||
const relays = [url]
|
const relays = [url]
|
||||||
const since = ago(MONTH)
|
const since = ago(MONTH)
|
||||||
|
|
||||||
// Load all groups for this space to populate navigation. It would be nice to sync, but relay29
|
// Load groups, threads, comments, and recent messages for user rooms to help with a quick page transition
|
||||||
// is too picky about how requests are built.
|
|
||||||
load({relays, filters: [{kinds: [GROUPS]}]})
|
|
||||||
|
|
||||||
// Load threads, comments, and recent messages for user rooms to help with a quick page transition
|
|
||||||
pullConservatively({
|
pullConservatively({
|
||||||
relays,
|
relays,
|
||||||
filters: [
|
filters: [
|
||||||
@@ -68,8 +64,8 @@
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
// Listen for deletes that would apply to messages we already have, and new groups
|
// Completely refresh our groups list and listen for new ones
|
||||||
const req = request({relays, filters: [{kinds: [DELETE, GROUPS], since}]})
|
const req = request({relays, filters: [{kinds: [GROUPS]}]})
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
req.close()
|
req.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user