mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-30 00:41:12 +00:00
Only hide replies on feeds
This commit is contained in:
parent
59c4fec4f0
commit
7cc9ebc080
@ -47,6 +47,7 @@ If you like Coracle and want to support its development, you can donate sats via
|
|||||||
|
|
||||||
- [ ] Everything waits for even the slowest relay to connect before returning events
|
- [ ] Everything waits for even the slowest relay to connect before returning events
|
||||||
- [ ] Alerts are not showing likes, just generally screwy. Maybe because I threadify before adding to the db?
|
- [ ] Alerts are not showing likes, just generally screwy. Maybe because I threadify before adding to the db?
|
||||||
|
- [ ] Change network tab to list relays the user is connected to
|
||||||
- [ ] Sync mentions box and in-reply mentions
|
- [ ] Sync mentions box and in-reply mentions
|
||||||
- [ ] Add petnames for channels
|
- [ ] Add petnames for channels
|
||||||
- [ ] Add notifications for chat messages
|
- [ ] Add notifications for chat messages
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {whereEq, sortBy, identity, when, assoc, reject} from 'ramda'
|
import {pluck, whereEq, sortBy, identity, when, assoc, reject} from 'ramda'
|
||||||
import {navigate} from 'svelte-routing'
|
import {navigate} from 'svelte-routing'
|
||||||
import {createMap, ellipsize} from 'hurdak/lib/hurdak'
|
import {createMap, ellipsize} from 'hurdak/lib/hurdak'
|
||||||
import {get} from 'svelte/store'
|
import {get} from 'svelte/store'
|
||||||
@ -124,9 +124,8 @@ export const annotate = (note, context) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const threadify = (events, context, {muffle = []} = {}) => {
|
export const threadify = (events, context, {muffle = [], showReplies = true} = {}) => {
|
||||||
const contextById = createMap('id', events.concat(context))
|
const contextById = createMap('id', events.concat(context))
|
||||||
|
|
||||||
// Show parents when possible. For reactions, if there's no parent,
|
// Show parents when possible. For reactions, if there's no parent,
|
||||||
// throw it away. Sort by created date descending
|
// throw it away. Sort by created date descending
|
||||||
const notes = sortBy(
|
const notes = sortBy(
|
||||||
@ -136,6 +135,23 @@ export const threadify = (events, context, {muffle = []} = {}) => {
|
|||||||
.filter(e => e && !muffle.includes(e.pubkey))
|
.filter(e => e && !muffle.includes(e.pubkey))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (!showReplies) {
|
||||||
|
return notes.filter(note => !findReplyId(note)).map(n => annotate(n, context))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't show notes that will also show up as children
|
||||||
|
const noteIds = new Set(pluck('id', notes))
|
||||||
|
|
||||||
// Annotate our feed with parents, reactions, replies.
|
// Annotate our feed with parents, reactions, replies.
|
||||||
return notes.filter(note => !findReplyId(note)).map(n => annotate(n, context))
|
return notes
|
||||||
|
.filter(note => !noteIds.has(findReplyId(note)))
|
||||||
|
.map(note => {
|
||||||
|
let parent = contextById[findReplyId(note)]
|
||||||
|
|
||||||
|
if (parent) {
|
||||||
|
parent = annotate(parent, context)
|
||||||
|
}
|
||||||
|
|
||||||
|
return annotate({...note, parent}, context)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
listen(relays, {...filter, since: now()}, batch(300, async notes => {
|
listen(relays, {...filter, since: now()}, batch(300, async notes => {
|
||||||
const context = await loaders.loadContext(relays, notes)
|
const context = await loaders.loadContext(relays, notes)
|
||||||
|
|
||||||
onNotes(threadify(notes, context, {muffle: getMuffle()}))
|
onNotes(threadify(notes, context, {muffle: getMuffle(), showReplies: false}))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const loadNotes = async () => {
|
const loadNotes = async () => {
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
cursor.onChunk(notes)
|
cursor.onChunk(notes)
|
||||||
|
|
||||||
return threadify(notes, context, {muffle: getMuffle()})
|
return threadify(notes, context, {muffle: getMuffle(), showReplies: false})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
listen(relays, {...filter, since: now()}, batch(300, async notes => {
|
listen(relays, {...filter, since: now()}, batch(300, async notes => {
|
||||||
const context = await loaders.loadContext(relays, notes)
|
const context = await loaders.loadContext(relays, notes)
|
||||||
|
|
||||||
onNotes(threadify(notes, context, {muffle: getMuffle()}))
|
onNotes(threadify(notes, context, {muffle: getMuffle(), showReplies: false}))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const loadNotes = async () => {
|
const loadNotes = async () => {
|
||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
cursor.onChunk(notes)
|
cursor.onChunk(notes)
|
||||||
|
|
||||||
return threadify(notes, context, {muffle: getMuffle()})
|
return threadify(notes, context, {muffle: getMuffle(), showReplies: false})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user