Don't show replies at top level of feeds

This commit is contained in:
Jonathan Staab 2023-01-23 20:14:48 -08:00
parent 9ceb3e3e74
commit c8fb7e7975
2 changed files with 9 additions and 17 deletions

View File

@ -1,4 +1,4 @@
import {pluck, whereEq, sortBy, identity, when, assoc, reject} from 'ramda'
import {whereEq, sortBy, identity, when, assoc, reject} from 'ramda'
import {navigate} from 'svelte-routing'
import {createMap, ellipsize} from 'hurdak/lib/hurdak'
import {get} from 'svelte/store'
@ -126,6 +126,7 @@ export const annotate = (note, context) => {
export const threadify = (events, context, {muffle = []} = {}) => {
const contextById = createMap('id', events.concat(context))
// Show parents when possible. For reactions, if there's no parent,
// throw it away. Sort by created date descending
const notes = sortBy(
@ -135,19 +136,6 @@ export const threadify = (events, context, {muffle = []} = {}) => {
.filter(e => e && !muffle.includes(e.pubkey))
)
// 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.
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)
})
return notes.filter(note => !findReplyId(note)).map(n => annotate(n, context))
}

View File

@ -79,10 +79,14 @@ setTimeout(() => {
const session = Math.random().toString().slice(2)
export const logUsage = name => {
export const logUsage = async name => {
const {dufflepudUrl, reportAnalytics} = get(settings)
if (reportAnalytics) {
fetch(`${dufflepudUrl}/usage/${session}/${name}`, {method: 'post' })
try {
await fetch(`${dufflepudUrl}/usage/${session}/${name}`, {method: 'post' })
} catch (e) {
console.warn(e)
}
}
}