mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-18 19:23:40 +00:00
Avoid fetching duplicate context, there seems to be an infinite loop that happens if we don't
This commit is contained in:
parent
770ed5b286
commit
1dd9c6f791
@ -21,12 +21,13 @@
|
|||||||
let notes = []
|
let notes = []
|
||||||
let notesBuffer = []
|
let notesBuffer = []
|
||||||
|
|
||||||
|
const seen = new Set()
|
||||||
const since = now()
|
const since = now()
|
||||||
const maxNotes = 100
|
const maxNotes = 100
|
||||||
const cursor = new Cursor()
|
const cursor = new Cursor()
|
||||||
|
|
||||||
const processNewNotes = async newNotes => {
|
const processNewNotes = async newNotes => {
|
||||||
newNotes = user.muffle(newNotes)
|
newNotes = user.muffle(newNotes).filter(n => !seen.has(n.id))
|
||||||
|
|
||||||
if (shouldDisplay) {
|
if (shouldDisplay) {
|
||||||
newNotes = newNotes.filter(shouldDisplay)
|
newNotes = newNotes.filter(shouldDisplay)
|
||||||
@ -73,6 +74,10 @@
|
|||||||
const chunk = sortBy(e => -e.created_at, await processNewNotes(newNotes))
|
const chunk = sortBy(e => -e.created_at, await processNewNotes(newNotes))
|
||||||
const [bottom, top] = partition(e => e.created_at < since, chunk)
|
const [bottom, top] = partition(e => e.created_at < since, chunk)
|
||||||
|
|
||||||
|
for (const note of chunk) {
|
||||||
|
seen.add(note.id)
|
||||||
|
}
|
||||||
|
|
||||||
// Slice new notes in case someone leaves the tab open for a long time
|
// Slice new notes in case someone leaves the tab open for a long time
|
||||||
notes = uniqBy(prop('id'), notes.concat(bottom))
|
notes = uniqBy(prop('id'), notes.concat(bottom))
|
||||||
notesBuffer = top.concat(notesBuffer).slice(0, maxNotes)
|
notesBuffer = top.concat(notesBuffer).slice(0, maxNotes)
|
||||||
|
Loading…
Reference in New Issue
Block a user