Fix a few bugs

This commit is contained in:
Jonathan Staab 2023-09-21 12:55:08 -07:00
parent 2c84739270
commit 683e4cd34e
5 changed files with 43 additions and 16 deletions

View File

@ -129,7 +129,7 @@
type: "profile",
text:
"@" +
[profile?.name, handle?.address, profile?.display_name].filter(identity).join(" "),
[profile?.name, profile?.display_name, handle?.address].filter(identity).join(" "),
}
})
)
@ -153,7 +153,7 @@
}
}
$: search = fuzzy(options, {keys: ["text"], threshold: 0.3})
$: search = fuzzy(options, {keys: ["text"], threshold: 0.5})
onMount(() => {
document.querySelector("html").addEventListener("click", e => {

View File

@ -142,7 +142,10 @@
replies = sortBy((e: Event) => -e.created_at, uniqBy(prop("id"), replies.concat(e)))
}
context = uniqBy(prop("id"), (context || []).concat(e))
context = sortBy(
(e: Event) => -e.created_at,
uniqBy(prop("id"), (context || []).concat(e))
)
}
},
"7": () => {

View File

@ -7,7 +7,14 @@
import Card from "src/partials/Card.svelte"
import Spinner from "src/partials/Spinner.svelte"
import PersonCircle from "src/app/shared/PersonCircle.svelte"
import {load, displayPubkey, isEventMuted, getEventHints, mergeHints} from "src/engine"
import {
load,
loadPubkeys,
displayPubkey,
isEventMuted,
getEventHints,
mergeHints,
} from "src/engine"
export let note
export let value
@ -39,6 +46,8 @@
loading = false
muted = isEventMuted(event).get()
quote = event
loadPubkeys([quote.pubkey])
},
})

View File

@ -11,7 +11,10 @@ export const matchFilter = (filter, event) => {
}
if (filter.search) {
return event.content.toLowerCase().includes(filter.search.toLowerCase())
const content = event.content.toLowerCase()
const terms = filter.search.toLowerCase().split(/\s+/g)
return any(s => content.includes(s), terms)
}
return true

View File

@ -49,6 +49,8 @@ export const listenForNotifications = async () => {
const pubkeys = Object.keys(sessions.get())
const channelIds = pluck("id", nip28ChannelsForUser.get())
const relays = mergeHints(pubkeys.map(pk => getPubkeyHints(pk, "read")))
const eventIds: string[] = doPipe(events.get(), [
filter((e: Event) => noteKinds.includes(e.kind)),
sortBy((e: Event) => -e.created_at),
@ -56,20 +58,30 @@ export const listenForNotifications = async () => {
pluck("id"),
])
const filters = [
// NIP04 Messages
{kinds: [4], "#p": pubkeys, limit: 1},
// NIP24 Messages
{kinds: [1059], "#p": pubkeys, limit: 1},
// Mentions
{kinds: noteKinds, "#p": pubkeys, limit: 1},
]
// Chat
if (channelIds.length > 0) {
filters.push({kinds: [42], "#e": channelIds, limit: 1})
}
// Replies
if (eventIds.length > 0) {
filters.push({kinds: noteKinds, "#e": eventIds, limit: 1})
}
// Only grab one event from each category/relay so we have enough to show
// the notification badges, but load the details lazily
subscribePersistent({
relays: mergeHints(pubkeys.map(pk => getPubkeyHints(pk, "read"))),
filters: [
// Messages
{kinds: [4], "#p": pubkeys, limit: 1},
{kinds: [1059], "#p": pubkeys, limit: 1},
// Chat
{kinds: [42], "#e": channelIds, limit: 1},
// Mentions/replies
{kinds: noteKinds, "#p": pubkeys, limit: 1},
{kinds: noteKinds, "#e": eventIds, limit: 1},
],
relays,
filters,
onEvent: (e: Event) => {
if (kinds.includes(e.kind) && !isEventMuted(e).get()) {
events.key(e.id).set(e)