mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-29 16:31:04 +00:00
Fix a few bugs
This commit is contained in:
parent
2c84739270
commit
683e4cd34e
@ -129,7 +129,7 @@
|
|||||||
type: "profile",
|
type: "profile",
|
||||||
text:
|
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(() => {
|
onMount(() => {
|
||||||
document.querySelector("html").addEventListener("click", e => {
|
document.querySelector("html").addEventListener("click", e => {
|
||||||
|
@ -142,7 +142,10 @@
|
|||||||
replies = sortBy((e: Event) => -e.created_at, uniqBy(prop("id"), replies.concat(e)))
|
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": () => {
|
"7": () => {
|
||||||
|
@ -7,7 +7,14 @@
|
|||||||
import Card from "src/partials/Card.svelte"
|
import Card from "src/partials/Card.svelte"
|
||||||
import Spinner from "src/partials/Spinner.svelte"
|
import Spinner from "src/partials/Spinner.svelte"
|
||||||
import PersonCircle from "src/app/shared/PersonCircle.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 note
|
||||||
export let value
|
export let value
|
||||||
@ -39,6 +46,8 @@
|
|||||||
loading = false
|
loading = false
|
||||||
muted = isEventMuted(event).get()
|
muted = isEventMuted(event).get()
|
||||||
quote = event
|
quote = event
|
||||||
|
|
||||||
|
loadPubkeys([quote.pubkey])
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -11,7 +11,10 @@ export const matchFilter = (filter, event) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filter.search) {
|
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
|
return true
|
||||||
|
@ -49,6 +49,8 @@ export const listenForNotifications = async () => {
|
|||||||
const pubkeys = Object.keys(sessions.get())
|
const pubkeys = Object.keys(sessions.get())
|
||||||
const channelIds = pluck("id", nip28ChannelsForUser.get())
|
const channelIds = pluck("id", nip28ChannelsForUser.get())
|
||||||
|
|
||||||
|
const relays = mergeHints(pubkeys.map(pk => getPubkeyHints(pk, "read")))
|
||||||
|
|
||||||
const eventIds: string[] = doPipe(events.get(), [
|
const eventIds: string[] = doPipe(events.get(), [
|
||||||
filter((e: Event) => noteKinds.includes(e.kind)),
|
filter((e: Event) => noteKinds.includes(e.kind)),
|
||||||
sortBy((e: Event) => -e.created_at),
|
sortBy((e: Event) => -e.created_at),
|
||||||
@ -56,20 +58,30 @@ export const listenForNotifications = async () => {
|
|||||||
pluck("id"),
|
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
|
// Only grab one event from each category/relay so we have enough to show
|
||||||
// the notification badges, but load the details lazily
|
// the notification badges, but load the details lazily
|
||||||
subscribePersistent({
|
subscribePersistent({
|
||||||
relays: mergeHints(pubkeys.map(pk => getPubkeyHints(pk, "read"))),
|
relays,
|
||||||
filters: [
|
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},
|
|
||||||
],
|
|
||||||
onEvent: (e: Event) => {
|
onEvent: (e: Event) => {
|
||||||
if (kinds.includes(e.kind) && !isEventMuted(e).get()) {
|
if (kinds.includes(e.kind) && !isEventMuted(e).get()) {
|
||||||
events.key(e.id).set(e)
|
events.key(e.id).set(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user