Improve group loading
This commit is contained in:
parent
2041ec6a7d
commit
cf074bd222
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {Tags} from "paravel"
|
||||
import {Tags, decodeAddress} from "paravel"
|
||||
import {sleep} from "hurdak"
|
||||
import {generatePrivateKey} from "src/util/nostr"
|
||||
import FlexColumn from "src/partials/FlexColumn.svelte"
|
||||
|
@ -12,6 +12,7 @@
|
|||
env,
|
||||
load,
|
||||
user,
|
||||
hints,
|
||||
session,
|
||||
loadPubkeys,
|
||||
publishNote,
|
||||
|
@ -69,11 +70,15 @@
|
|||
}
|
||||
|
||||
onMount(async () => {
|
||||
// Prime our database with our default follows
|
||||
loadPubkeys($env.DEFAULT_FOLLOWS)
|
||||
const {DEFAULT_FOLLOWS, ONBOARDING_LISTS} = $env
|
||||
const listOwners = ONBOARDING_LISTS.map(a => decodeAddress(a).pubkey)
|
||||
|
||||
// Prime our database with our default follows and list owners
|
||||
loadPubkeys([...DEFAULT_FOLLOWS, ...listOwners])
|
||||
|
||||
// Load our onboarding lists
|
||||
load({
|
||||
relays: $env.DEFAULT_RELAYS,
|
||||
relays: hints.FromPubkeys(listOwners).getUrls(),
|
||||
filters: getIdFilters($env.ONBOARDING_LISTS),
|
||||
onEvent: e => {
|
||||
loadPubkeys(Tags.fromEvent(e).values("p").valueOf())
|
||||
|
@ -98,18 +103,18 @@
|
|||
<div
|
||||
class="h-2 w-2 rounded-full"
|
||||
class:bg-neutral-200={stage === "intro"}
|
||||
class:bg-neutral-600={stage !== "intro"} />
|
||||
class:bg-neutral-700={stage !== "intro"} />
|
||||
<div
|
||||
class="h-2 w-2 rounded-full"
|
||||
class:bg-neutral-200={stage === "profile"}
|
||||
class:bg-neutral-600={stage !== "profile"} />
|
||||
class:bg-neutral-700={stage !== "profile"} />
|
||||
<div
|
||||
class="h-2 w-2 rounded-full"
|
||||
class:bg-neutral-200={stage === "follows"}
|
||||
class:bg-neutral-600={stage !== "follows"} />
|
||||
class:bg-neutral-700={stage !== "follows"} />
|
||||
<div
|
||||
class="h-2 w-2 rounded-full"
|
||||
class:bg-neutral-200={stage === "note"}
|
||||
class:bg-neutral-600={stage !== "note"} />
|
||||
class:bg-neutral-700={stage !== "note"} />
|
||||
</div>
|
||||
</FlexColumn>
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
|
||||
<div class="flex gap-3">
|
||||
<p
|
||||
class="-ml-1 -mt-2 flex h-12 w-12 items-center justify-center rounded-full bg-neutral-600 text-lg">
|
||||
class="-ml-1 -mt-2 flex h-12 w-12 items-center justify-center rounded-full bg-neutral-700 text-lg">
|
||||
3/4
|
||||
</p>
|
||||
<p class="text-2xl font-bold">Find your people</p>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</script>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<p class="-ml-1 -mt-2 flex h-12 w-12 items-center justify-center rounded-full bg-neutral-600 text-lg">
|
||||
<p class="-ml-1 -mt-2 flex h-12 w-12 items-center justify-center rounded-full bg-neutral-700 text-lg">
|
||||
1/4
|
||||
</p>
|
||||
<p class="text-2xl font-bold">New to Nostr?</p>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
<div class="flex gap-3">
|
||||
<p
|
||||
class="-ml-1 -mt-2 flex h-12 w-12 items-center justify-center rounded-full bg-neutral-600 text-lg">
|
||||
class="-ml-1 -mt-2 flex h-12 w-12 items-center justify-center rounded-full bg-neutral-700 text-lg">
|
||||
4/4
|
||||
</p>
|
||||
<p class="text-2xl font-bold">You're all set!</p>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</script>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<p class="-ml-1 -mt-2 flex h-12 w-12 items-center justify-center rounded-full bg-neutral-600 text-lg">
|
||||
<p class="-ml-1 -mt-2 flex h-12 w-12 items-center justify-center rounded-full bg-neutral-700 text-lg">
|
||||
2/4
|
||||
</p>
|
||||
<p class="text-2xl font-bold">Give us something to go on!</p>
|
||||
|
|
|
@ -4,6 +4,7 @@ import {partition} from "ramda"
|
|||
import {noteKinds, giftWrapKinds, repostKinds} from "src/util/nostr"
|
||||
import {load} from "src/engine/network/utils"
|
||||
import {hints} from "src/engine/relays/utils"
|
||||
import {env} from "src/engine/session/state"
|
||||
import {updateCurrentSession} from "src/engine/session/commands"
|
||||
import {groups} from "./state"
|
||||
import {deriveUserCircles, getGroupReqInfo, getCommunityReqInfo} from "./utils"
|
||||
|
@ -40,7 +41,11 @@ export const loadGroups = async (rawAddrs: string[], relays: string[] = []) => {
|
|||
if (addrs.length > 0) {
|
||||
load({
|
||||
relays: hints
|
||||
.merge([hints.scenario([relays]), hints.WithinMultipleContexts(addrs)])
|
||||
.merge([
|
||||
hints.scenario([relays]),
|
||||
hints.WithinMultipleContexts(addrs),
|
||||
hints.scenario([env.get().PLATFORM_RELAYS]),
|
||||
])
|
||||
.getUrls(),
|
||||
filters: [{kinds: [34550, 35834], authors, "#d": identifiers}],
|
||||
})
|
||||
|
|
|
@ -3,7 +3,7 @@ import {ellipsize, seconds} from "hurdak"
|
|||
import {Tags, decodeAddress, addressToNaddr} from "paravel"
|
||||
import {fuzzy} from "src/util/misc"
|
||||
import type {GroupStatus, Session} from "src/engine/session/model"
|
||||
import {pubkey} from "src/engine/session/state"
|
||||
import {env, pubkey} from "src/engine/session/state"
|
||||
import {session} from "src/engine/session/derived"
|
||||
import {hints} from "src/engine/relays/utils"
|
||||
import {groups, groupSharedKeys, groupAdminKeys} from "./state"
|
||||
|
@ -72,7 +72,9 @@ export const getGroupReqInfo = (address = null) => {
|
|||
recipients.push(key.pubkey)
|
||||
}
|
||||
|
||||
const relays = hints.merge(addresses.map(hints.WithinContext)).getUrls()
|
||||
const relays = hints
|
||||
.merge([hints.WithinMultipleContexts(addresses), hints.scenario([env.get().PLATFORM_RELAYS])])
|
||||
.getUrls()
|
||||
|
||||
return {admins, recipients, relays, since}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import type {Event} from "nostr-tools"
|
||||
import {without, uniq} from "ramda"
|
||||
import {seconds} from "hurdak"
|
||||
import {now} from "paravel"
|
||||
|
@ -11,6 +12,7 @@ export type LoadPeopleOpts = {
|
|||
relays?: string[]
|
||||
kinds?: number[]
|
||||
force?: boolean
|
||||
onEvent?: (e: Event) => void
|
||||
}
|
||||
|
||||
export const attemptedPubkeys = new Map()
|
||||
|
@ -48,7 +50,7 @@ export const getStalePubkeys = (pubkeys: Iterable<string>) => {
|
|||
|
||||
export const loadPubkeys = async (
|
||||
rawPubkeys: Iterable<string>,
|
||||
{relays, force, kinds = personKinds}: LoadPeopleOpts = {},
|
||||
{relays, force, onEvent, kinds = personKinds}: LoadPeopleOpts = {},
|
||||
) => {
|
||||
const pubkeys = force ? uniq(Array.from(rawPubkeys)) : getStalePubkeys(rawPubkeys)
|
||||
|
||||
|
@ -68,6 +70,7 @@ export const loadPubkeys = async (
|
|||
|
||||
return load({
|
||||
filters,
|
||||
onEvent,
|
||||
relays: hints.merge([hints.scenario([relays]), hints.FromPubkeys(pubkeys)]).getUrls(),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue