From c8fb7e7975c3fc9e50f605de0bfb2bb7050d2095 Mon Sep 17 00:00:00 2001 From: Jonathan Staab Date: Mon, 23 Jan 2023 20:14:48 -0800 Subject: [PATCH] Don't show replies at top level of feeds --- src/app/index.js | 18 +++--------------- src/app/ui.js | 8 ++++++-- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/app/index.js b/src/app/index.js index 82ed8480..cc4fb344 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -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)) } diff --git a/src/app/ui.js b/src/app/ui.js index 3bd58ef0..b34ebbe7 100644 --- a/src/app/ui.js +++ b/src/app/ui.js @@ -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) + } } }