Skip to content

Commit

Permalink
make trackRelays always true.
Browse files Browse the repository at this point in the history
  • Loading branch information
AsaiToshiya authored and fiatjaf committed Nov 7, 2024
1 parent 6fb64cf commit 84832c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
4 changes: 0 additions & 4 deletions src/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export function Editor({

console.log('publishing...')

pool.current.trackRelays = true
let pub = Promise.allSettled(pool.current.publish(relays, event))
pub.then(async _ => {
clearTimeout(publishTimeout)
Expand All @@ -172,9 +171,6 @@ export function Editor({
setEditable(true)
})
})
.finally(() => {
pool.current.trackRelays = false
})
}

function showNotice(text) {
Expand Down
15 changes: 2 additions & 13 deletions src/NoComment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function NoComment({
const [metadata, setMetadata] = useState({})
const metadataFetching = useRef({})
const pool = useRef(new SimplePool())
pool.current.trackRelays = true
const [baseTag] = useDebounce(baseTagImmediate, 1000)
const [events] = useDebounce(eventsImmediate, 1000, {leading: true})
const threads = useMemo(() => {
Expand Down Expand Up @@ -77,7 +78,6 @@ export function NoComment({
filter = {ids: [id]}
}

pool.current.trackRelays = true
pool.current.get(relays, filter)
.then(event => {
relay = relay || Array.from(pool.current.seenOn.get(event.id))[0].url
Expand Down Expand Up @@ -119,17 +119,13 @@ export function NoComment({
})
}
})
.finally(() => {
pool.current.trackRelays = false
})
}
}, [customBase])

useEffect(() => {
if (customBase) return

// search for the base event based on the #r tag (url)
pool.current.trackRelays = true
pool.current
.querySync(chosenRelays, {
'#r': [url],
Expand Down Expand Up @@ -163,16 +159,12 @@ export function NoComment({
parentReference
})
})
.finally(() => {
pool.current.trackRelays = false
})
}, [chosenRelays.length])

useEffect(() => {
if (!baseTag) return

// query for comments
pool.current.trackRelays = true
let sub = pool.current.subscribeMany(chosenRelays, baseTag.filters, {
onevent(event) {
setEvents(events => insertEventIntoDescendingList(events, event))
Expand All @@ -183,10 +175,7 @@ export function NoComment({

let i = 0

return () => {
sub.close()
pool.current.trackRelays = false
}
return () => sub.close()
}, [baseTag, chosenRelays.length])

if (skip && skip !== '' && skip === location.pathname) {
Expand Down

0 comments on commit 84832c6

Please sign in to comment.