Speed up data loading, make it more lazy

This commit is contained in:
Jon Staab
2024-08-14 09:28:26 -07:00
parent 5bec4531ea
commit d26bac8a42
5 changed files with 49 additions and 76 deletions
+2 -6
View File
@@ -10,7 +10,7 @@
import {pushModal, clearModal} from '@app/modal'
import {pushToast} from '@app/toast'
import {addSession} from '@app/base'
import {loadUserData, loadHandle} from '@app/state'
import {loadHandle} from '@app/state'
const back = () => history.back()
@@ -27,12 +27,8 @@
const {pubkey, relays = []} = handle
const broker = Nip46Broker.get(pubkey, secret, handler)
const [profile, success] = await Promise.all([
loadUserData(pubkey, relays),
broker.connect(),
])
if (success) {
if (await broker.connect()) {
addSession({method: "nip46", pubkey, secret, handler})
pushToast({message: "Successfully logged in!"})
clearModal()
+4 -2
View File
@@ -13,7 +13,7 @@
import PrimaryNavItem from "@lib/components/PrimaryNavItem.svelte"
import SpaceAdd from '@app/components/SpaceAdd.svelte'
import {session} from "@app/base"
import {deriveGroupMembership, makeGroupId, getGroup, deriveProfile, qualifiedGroupsById, getGroupNom} from "@app/state"
import {deriveGroupMembership, makeGroupId, loadGroup, deriveProfile, qualifiedGroupsById, splitGroupId} from "@app/state"
import {pushModal} from "@app/modal"
const addSpace = () => pushModal(SpaceAdd)
@@ -27,10 +27,12 @@
const $userGroupsByNom = new Map()
for (const id of $membership?.ids || []) {
const nom = getGroupNom(id)
const [url, nom] = splitGroupId(id)
const group = $qualifiedGroupsById.get(id)
const groups = $userGroupsByNom.get(nom) || []
loadGroup(nom, [url])
if (group) {
groups.push(group)
}