Move loadUserData to requests

This commit is contained in:
Jon Staab
2025-02-14 11:12:19 -08:00
parent e484c3cb00
commit b05c408977
8 changed files with 99 additions and 76 deletions
+2 -2
View File
@@ -67,8 +67,8 @@
import {nsecDecode} from "@lib/util"
import {theme} from "@app/theme"
import {INDEXER_RELAYS, userMembership, ensureUnwrapped, canDecrypt} from "@app/state"
import {loadUserData, loginWithNip46} from "@app/commands"
import {listenForNotifications} from "@app/requests"
import {loadUserData, listenForNotifications} from "@app/requests"
import {loginWithNip46} from "@app/commands"
import * as commands from "@app/commands"
import * as requests from "@app/requests"
import * as notifications from "@app/notifications"
+17 -14
View File
@@ -20,7 +20,7 @@
userRoomsByUrl,
getDefaultPubkeys,
} from "@app/state"
import {discoverRelays} from "@app/commands"
import {discoverRelays} from "@app/requests"
import {pushModal} from "@app/modal"
const wotGraph = $derived.by(() => {
@@ -36,20 +36,23 @@
})
const relaySearch = $derived(
createSearch($relays, {
getValue: (relay: Relay) => relay.url,
sortFn: ({score, item}) => {
if (score && score > 0.1) return -score!
createSearch(
$relays.filter(r => wotGraph.has(r.url)),
{
getValue: (relay: Relay) => relay.url,
sortFn: ({score, item}) => {
if (score && score > 0.1) return -score!
const wotScore = wotGraph.get(item.url)?.size || 0
const wotScore = wotGraph.get(item.url)?.size || 0
return score ? dec(score) * wotScore : -wotScore
return score ? dec(score) * wotScore : -wotScore
},
fuseOptions: {
keys: ["url", "name", {name: "description", weight: 0.3}],
shouldSort: false,
},
},
fuseOptions: {
keys: ["url", "name", {name: "description", weight: 0.3}],
shouldSort: false,
},
}),
),
)
const openSpace = (url: string) => pushModal(SpaceCheck, {url})
@@ -129,8 +132,8 @@
</Button>
{/each}
{#await discoverRelays($memberships)}
<div class="flex justify-center">
<Spinner loading>Loading more relays...</Spinner>
<div class="flex justify-center py-20">
<Spinner loading>Loading spaces...</Spinner>
</div>
{/await}
</div>
+2 -1
View File
@@ -16,7 +16,8 @@
import RelayItem from "@app/components/RelayItem.svelte"
import RelayAdd from "@app/components/RelayAdd.svelte"
import {pushModal} from "@app/modal"
import {setRelayPolicy, discoverRelays, setInboxRelayPolicy} from "@app/commands"
import {discoverRelays} from "@app/requests"
import {setRelayPolicy, setInboxRelayPolicy} from "@app/commands"
const readRelayUrls = derived(userRelaySelections, getReadRelayUrls)
const writeRelayUrls = derived(userRelaySelections, getWriteRelayUrls)