mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-29 00:10:52 +00:00
Fix mutes, improve performance
This commit is contained in:
parent
c5b11be1bb
commit
7a73f443a9
@ -13,7 +13,7 @@
|
||||
import NoteReply from "src/app/shared/NoteReply.svelte"
|
||||
import NoteActions from "src/app/shared/NoteActions.svelte"
|
||||
import Card from "src/partials/Card.svelte"
|
||||
import {nip05, user, directory, nip65, nip02} from "src/app/engine"
|
||||
import {Nip05, Keys, User, directory, Nip65, Nip02} from "src/app/engine"
|
||||
import NoteContent from "src/app/shared/NoteContent.svelte"
|
||||
|
||||
export let note
|
||||
@ -36,8 +36,8 @@
|
||||
const showEntire = anchorId === note.id
|
||||
const interactive = !anchorId || !showEntire
|
||||
const author = directory.profiles.key(note.pubkey).derived(defaultTo({pubkey: note.pubkey}))
|
||||
const muted = nip02.graph.derived(() => user.isIgnoring(note.id))
|
||||
const handle = nip05.handles.key(note.pubkey)
|
||||
const muted = Nip02.graph.key(Keys.pubkey.get()).derived(() => User.isIgnoring(note.id))
|
||||
const handle = Nip05.handles.key(note.pubkey)
|
||||
|
||||
let border, childrenContainer, noteContainer
|
||||
|
||||
@ -60,13 +60,13 @@
|
||||
}
|
||||
|
||||
const goToParent = async () => {
|
||||
const relays = nip65.getParentHints(3, note)
|
||||
const relays = Nip65.getParentHints(3, note)
|
||||
|
||||
goToNote({note: {id: findReplyId(note)}, relays})
|
||||
}
|
||||
|
||||
const goToRoot = async () => {
|
||||
const relays = nip65.getParentHints(3, note)
|
||||
const relays = Nip65.getParentHints(3, note)
|
||||
|
||||
goToNote({note: {id: findRootId(note)}, relays})
|
||||
}
|
||||
|
@ -43,9 +43,9 @@
|
||||
|
||||
const quote = () => modal.push({type: "note/create", quote: note})
|
||||
|
||||
const unmute = () => user.unmute(note.pubkey)
|
||||
const unmute = () => user.unmute(note.id)
|
||||
|
||||
const mute = () => user.mute("p", note.pubkey)
|
||||
const mute = () => user.mute("e", note.id)
|
||||
|
||||
const react = async content => {
|
||||
const relays = nip65.getPublishHints(3, note, user.getRelayUrls("write"))
|
||||
|
@ -18,7 +18,7 @@
|
||||
const feed = network.feed({
|
||||
limit: 1,
|
||||
depth: 6,
|
||||
relays: nip65.selectHints(3, relays),
|
||||
relays: nip65.selectHints(10, relays),
|
||||
filter: {ids: [note.id]},
|
||||
})
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
await feed.loadAll()
|
||||
|
||||
console.log('NoteDetail', $displayNote)
|
||||
console.log("NoteDetail", $displayNote)
|
||||
|
||||
loading = false
|
||||
})
|
||||
|
@ -91,7 +91,8 @@
|
||||
document.title = "Notifications"
|
||||
|
||||
const pubkey = Keys.pubkey.get()
|
||||
const since = lastChecked - seconds(30, "day")
|
||||
const since = Math.max(lastChecked - seconds(1, "hour"), now() - seconds(30, "day"))
|
||||
|
||||
const reactionKinds = ENABLE_ZAPS ? [7, 9735] : [7]
|
||||
const eventIds = doPipe(Events.cache.get(), [
|
||||
filter(e => noteKinds.includes(e.kind)),
|
||||
|
@ -14,6 +14,7 @@ export type SubscribeOpts = {
|
||||
filter: Filter[] | Filter
|
||||
onEvent?: (event: Event) => void
|
||||
onEose?: (url: string) => void
|
||||
onClose?: () => void
|
||||
timeout?: number
|
||||
shouldProcess?: boolean
|
||||
}
|
||||
@ -185,6 +186,7 @@ export class Network {
|
||||
filter,
|
||||
onEose,
|
||||
onEvent,
|
||||
onClose,
|
||||
timeout,
|
||||
shouldProcess = true,
|
||||
}: SubscribeOpts) => {
|
||||
@ -204,6 +206,7 @@ export class Network {
|
||||
sub.unsubscribe()
|
||||
executor.target.cleanup()
|
||||
Network.emitter.emit("sub:close", urls)
|
||||
onClose?.()
|
||||
})
|
||||
|
||||
if (timeout) {
|
||||
|
@ -102,7 +102,7 @@ export class Nip02 {
|
||||
Nip02.graph.key(e.pubkey).merge({
|
||||
updated_at: now(),
|
||||
mutes_updated_at: e.created_at,
|
||||
mutes: Tags.from(e).type("p").all(),
|
||||
mutes: Tags.from(e).type(["e", "p"]).all(),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ export class Cursor {
|
||||
let count = 0
|
||||
|
||||
return this.opts.subscribe({
|
||||
timeout: 10_000,
|
||||
timeout: 4000,
|
||||
relays: [relay],
|
||||
filter: ensurePlural(filter).map(mergeLeft({until, limit})),
|
||||
onEvent: event => {
|
||||
@ -54,6 +54,10 @@ export class Cursor {
|
||||
this.loading = false
|
||||
this.done = count < limit
|
||||
},
|
||||
onClose: () => {
|
||||
this.loading = false
|
||||
this.done = true
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ export class Feed {
|
||||
loadParents = events => {
|
||||
const {Network, Nip65} = this.opts.engine
|
||||
const parentsInfo = events
|
||||
.map(e => ({id: findReplyId(e), hints: Nip65.getParentHints(3, e)}))
|
||||
.map(e => ({id: findReplyId(e), hints: Nip65.getParentHints(10, e)}))
|
||||
.filter(({id}) => id && !this.seen.has(id))
|
||||
|
||||
if (parentsInfo.length > 0) {
|
||||
@ -220,7 +220,7 @@ export class Feed {
|
||||
for (const c of chunk(256, events)) {
|
||||
Network.subscribe({
|
||||
timeout: 3000,
|
||||
relays: this.mergeHints(c.map(e => Nip65.getReplyHints(3, e))),
|
||||
relays: this.mergeHints(c.map(e => Nip65.getReplyHints(10, e))),
|
||||
filter: {kinds: this.getReplyKinds(), "#e": pluck("id", c)},
|
||||
onEvent: batch(100, context => this.addContext(context, {depth: depth - 1})),
|
||||
})
|
||||
@ -247,7 +247,7 @@ export class Feed {
|
||||
for (const c of chunk(256, findNotes(this.feed.get()))) {
|
||||
this.addSubs("listeners", [
|
||||
Network.subscribe({
|
||||
relays: this.mergeHints(c.map(e => Nip65.getReplyHints(3, e))),
|
||||
relays: this.mergeHints(c.map(e => Nip65.getReplyHints(10, e))),
|
||||
filter: {kinds: this.getReplyKinds(), "#e": pluck("id", c), since: now()},
|
||||
onEvent: batch(100, context => this.addContext(context, {depth: 2})),
|
||||
}),
|
||||
|
Loading…
Reference in New Issue
Block a user