Load people from the networking in EnsureData too

This commit is contained in:
Jonathan Staab 2023-04-18 12:44:41 -05:00
parent 67d1162245
commit c033b66b64
2 changed files with 29 additions and 22 deletions

View File

@ -1,5 +1,6 @@
<script>
import {nth} from "ramda"
import {debounce} from "throttle-debounce"
import Input from "src/partials/Input.svelte"
import Spinner from "src/partials/Spinner.svelte"
import PersonInfo from "src/app/shared/PersonInfo.svelte"
@ -12,6 +13,19 @@
let q
const {petnames} = user
const loadPeople = debounce(500, search => {
if (q.length > 2) {
network.load({
relays: getUserReadRelays(),
filter: [{kinds: [0], search, limit: 10}],
})
}
})
$: loadPeople(q)
$: results = $searchPeople(q)
.filter(person => {
if (person.pubkey === user.getPubkey()) {
@ -25,14 +39,6 @@
return true
})
.slice(0, 50)
const {petnames} = user
// Prime our database, in case we don't have any people stored yet
network.load({
relays: getUserReadRelays(),
filter: {kinds: [0], limit: 10},
})
</script>
<Input bind:value={q} placeholder="Search for people">

View File

@ -15,7 +15,21 @@
let q
$: searchPeople(q)
const openTopic = topic => {
modal.push({type: "topic/feed", topic})
}
const loadPeople = debounce(500, search => {
if (q.length > 2) {
network.load({
relays: getUserReadRelays(),
filter: [{kinds: [0], search, limit: 10}],
})
}
})
$: loadPeople(q)
$: search = watch(["people", "topics"], (p, t) => {
const topics = t
.all()
@ -33,19 +47,6 @@
return fuzzy(sortBy(prop("id"), topics.concat(people)), {keys: ["text"]})
})
const openTopic = topic => {
modal.push({type: "topic/feed", topic})
}
const searchPeople = debounce(500, search => {
if (q.length > 2) {
network.load({
relays: getUserReadRelays(),
filter: [{kinds: [0], search, limit: 10}],
})
}
})
document.title = "Search"
</script>