mirror of
https://github.com/coracle-social/coracle.git
synced 2024-10-01 17:31:24 +00:00
Fix search
This commit is contained in:
parent
f5aae29582
commit
a3ae2e9940
@ -26,12 +26,7 @@ Coracle is currently in _alpha_ - expect bugs, slow loading times, and rough edg
|
|||||||
# Bugs
|
# Bugs
|
||||||
|
|
||||||
- [ ] Use https://nostr.watch/relays.json to populate relays
|
- [ ] Use https://nostr.watch/relays.json to populate relays
|
||||||
- [ ] Completely redo notes fetching, it's buggy as heck
|
|
||||||
- [ ] uniq and sortBy are sprinkled all over the place, figure out a better solution
|
|
||||||
- [ ] Search page is slow and likes don't show up. Probably move this server-side
|
|
||||||
- [ ] User detail is not filtering by author
|
|
||||||
- [ ] Add alerts for replies to posts the user liked
|
- [ ] Add alerts for replies to posts the user liked
|
||||||
- [ ] Support bech32 keys/add guide on how to convert
|
|
||||||
- [ ] With link/image previews, remove the url from the note body if it's on a separate last line
|
- [ ] With link/image previews, remove the url from the note body if it's on a separate last line
|
||||||
- [ ] Stack views so scroll position isn't lost on navigation
|
- [ ] Stack views so scroll position isn't lost on navigation
|
||||||
- [ ] We're sending client=astral tags, event id 125ff9dc495f65d302e8d95ea6f9385106cc31b81c80e8c582b44be92fa50c44
|
- [ ] We're sending client=astral tags, event id 125ff9dc495f65d302e8d95ea6f9385106cc31b81c80e8c582b44be92fa50c44
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
<script>
|
<script>
|
||||||
import {take} from 'ramda'
|
import {take} from 'ramda'
|
||||||
|
import {onMount} from 'svelte'
|
||||||
import {fly} from 'svelte/transition'
|
import {fly} from 'svelte/transition'
|
||||||
import {fuzzy} from "src/util/misc"
|
import {fuzzy} from "src/util/misc"
|
||||||
import Note from "src/partials/Note.svelte"
|
import Note from "src/partials/Note.svelte"
|
||||||
import relay from 'src/relay'
|
import Spinner from "src/partials/Spinner.svelte"
|
||||||
|
|
||||||
export let q
|
export let q
|
||||||
|
|
||||||
let results = []
|
let search
|
||||||
|
|
||||||
const search = relay.lq(async () => {
|
onMount(async () => {
|
||||||
const notes = take(5000, await relay.filterEvents({kinds: [1]}))
|
search = fuzzy(
|
||||||
|
take(5000, await relay.filterEvents({kinds: [1]})),
|
||||||
return fuzzy(notes, {keys: ["content"]})
|
{keys: ["content"]}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
$: {
|
|
||||||
if ($search) {
|
|
||||||
Promise.all(
|
|
||||||
$search(q).map(n => relay.findNote(n.id))
|
|
||||||
).then(notes => {
|
|
||||||
results = notes
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if search}
|
||||||
<ul class="py-8 flex flex-col gap-2 max-w-xl m-auto">
|
<ul class="py-8 flex flex-col gap-2 max-w-xl m-auto">
|
||||||
{#each results.slice(0, 50) as e (e.id)}
|
{#await Promise.all(search(q).slice(0, 30).map(n => relay.findNote(n.id)))}
|
||||||
|
<Spinner />
|
||||||
|
{:then results}
|
||||||
|
{#each results as e (e.id)}
|
||||||
<li in:fly={{y: 20}}>
|
<li in:fly={{y: 20}}>
|
||||||
<Note interactive note={e} />
|
<Note interactive note={e} />
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
|
{/await}
|
||||||
</ul>
|
</ul>
|
||||||
|
{:else}
|
||||||
|
<Spinner />
|
||||||
|
{/if}
|
||||||
|
@ -1,18 +1,13 @@
|
|||||||
<script>
|
<script>
|
||||||
import {fly} from 'svelte/transition'
|
import {fly} from 'svelte/transition'
|
||||||
import {fuzzy} from "src/util/misc"
|
import {fuzzy} from "src/util/misc"
|
||||||
import relay, {user} from 'src/relay'
|
import {user, people} from 'src/relay'
|
||||||
|
|
||||||
export let q
|
export let q
|
||||||
|
|
||||||
let search
|
let search = fuzzy(Object.values($people), {keys: ["name", "about", "pubkey"]})
|
||||||
|
|
||||||
const people = relay.lq(() => relay.db.people.toArray())
|
|
||||||
|
|
||||||
$: search = fuzzy($people || [], {keys: ["name", "about", "pubkey"]})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if search}
|
|
||||||
<ul class="py-8 flex flex-col gap-2 max-w-xl m-auto">
|
<ul class="py-8 flex flex-col gap-2 max-w-xl m-auto">
|
||||||
{#each search(q) as p (p.pubkey)}
|
{#each search(q) as p (p.pubkey)}
|
||||||
{#if p.pubkey !== $user.pubkey}
|
{#if p.pubkey !== $user.pubkey}
|
||||||
@ -30,4 +25,3 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
{/if}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user