diff --git a/e2e/specs/notifications.spec.ts b/e2e/specs/notifications.spec.ts index 2656a665..38fed6f2 100644 --- a/e2e/specs/notifications.spec.ts +++ b/e2e/specs/notifications.spec.ts @@ -419,6 +419,7 @@ test("US-117 read the network feed on home", async ({seed, as}) => { const note = "the tide charts are wrong again" const quiet = "the ferry is running on time" const reply = "they were reprinted last week" + const topic = "Dredging the channel" await seed(({relay, user}) => { const space = relay("space") @@ -445,6 +446,16 @@ test("US-117 read the network feed on home", async ({seed, as}) => { space.event(user.bob, () => space.kind(Note).writer().setParent(posted.event).setContent(reply).renderTemplate(), ) + + space.event(user.bob, () => + space + .kind(Thread) + .writer() + .setRoom(space.url, "general") + .setTitle(topic) + .setContent("The barges keep grounding.") + .renderTemplate(), + ) }) const page = await as(users.alice, "/home") @@ -460,6 +471,16 @@ test("US-117 read the network feed on home", async ({seed, as}) => { // The count is there whether or not anybody replied, so every note reads the same. await expect(page.getByText(quiet)).toBeVisible() await expect(page.getByRole("button", {name: "0 replies"})).toBeVisible() + + // The feed carries every kind of post a follow writes, not only their notes. + await expect(page.getByText(topic)).toBeVisible() + + // Every card says when it was posted. + const network = page + .locator("section") + .filter({has: page.getByRole("heading", {name: "Network"})}) + + await expect(network.getByRole("button", {name: /\d+\/\d+\/\d+/}).first()).toBeVisible() }) test("US-106 share text into the app", async ({seed, as}) => { diff --git a/src/app/components/HomeNetwork.svelte b/src/app/components/HomeNetwork.svelte index 4897c333..51eeda96 100644 --- a/src/app/components/HomeNetwork.svelte +++ b/src/app/components/HomeNetwork.svelte @@ -2,9 +2,9 @@ import {onDestroy} from "svelte" import {writable} from "svelte/store" import type {Writable} from "svelte/store" - import {sortBy} from "@welshman/lib" + import {sortBy, uniqBy} from "@welshman/lib" import type {Maybe} from "@welshman/lib" - import {NOTE, outbox} from "@welshman/util" + import {NOTE, getIdOrAddress, outbox} from "@welshman/util" import type {TrustedEvent} from "@welshman/util" import {getReplyTags} from "@welshman/domain" import Planet from "@assets/icons/planet.svg?dataurl" @@ -13,6 +13,7 @@ import Spinner from "@lib/components/Spinner.svelte" import HomeSection from "@app/components/HomeSection.svelte" import HomeNetworkItem from "@app/components/HomeNetworkItem.svelte" + import {CONTENT_KINDS} from "@app/content" import {followLists, relayLists, router, user} from "@app/core" import {isFeedLoading, makeFeed, makeFeedContext, makeScrollLoader} from "@app/feeds" @@ -36,23 +37,27 @@ let started = false let stop: Maybe<() => void> - // Replies are left out - without their parent they read as half a conversation. - const notes = $derived( - sortBy( - e => -e.created_at, - $events.filter(e => getReplyTags(e.tags).replies.length === 0), + // Kind 1 replies are left out - without their parent they read as half a conversation. Every + // other kind here is a root, and an edited one is shown once, at its latest version. + const isRoot = (event: TrustedEvent) => + event.kind !== NOTE || getReplyTags(event.tags).replies.length === 0 + + const items = $derived( + uniqBy( + getIdOrAddress, + sortBy(e => -e.created_at, $events.filter(isRoot)), ), ) const loading = $derived(isFeedLoading($older)) const exhausted = $derived($older?.status === "exhausted") - const isEmpty = $derived(follows?.length === 0 || (exhausted && notes.length === 0)) + const isEmpty = $derived(follows?.length === 0 || (exhausted && items.length === 0)) const start = async (pubkeys: string[]) => { const scenario = await $router.resolve(pubkeys.map(pubkey => outbox(pubkey))) const feed = makeFeed({ relays: scenario.limit(RELAY_LIMIT).getUrls(), - filters: [{kinds: [NOTE], authors: pubkeys}], + filters: [{kinds: [NOTE, ...CONTENT_KINDS], authors: pubkeys}], onEvent: context.add, }) @@ -85,16 +90,16 @@
Follow a few people to fill this out
- Notes from the people you follow collect here. Spaces are a good place to find some. + Posts from the people you follow collect here. Spaces are a good place to find some.
Browse spaces