From c7d5f7e167bfac0e25fca67151a755fb0ad71ef9 Mon Sep 17 00:00:00 2001 From: DS Boyce <260543580+ds-boyce@users.noreply.github.com> Date: Tue, 29 Sep 2026 09:39:09 -0700 Subject: [PATCH] Adopt canonical OP thread feed fields (#11822) --- src/lib/api/feed-manip.test.ts | 9 +++------ src/lib/api/feed-manip.ts | 15 ++++++--------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/lib/api/feed-manip.test.ts b/src/lib/api/feed-manip.test.ts index f5ae43c46..3e59dd31a 100644 --- a/src/lib/api/feed-manip.test.ts +++ b/src/lib/api/feed-manip.test.ts @@ -9,7 +9,7 @@ const author = { $type: 'app.bsky.actor.defs#profileViewBasic', did: 'did:plc:alice', handle: 'alice.test', -} as app.bsky.actor.defs.ProfileViewBasic +} satisfies app.bsky.actor.defs.ProfileViewBasic function post(id: string) { return { @@ -23,7 +23,7 @@ function post(id: string) { createdAt: '2026-08-31T00:00:00.000Z', }, indexedAt: '2026-08-31T00:00:00.000Z', - } as app.bsky.feed.defs.PostView + } satisfies app.bsky.feed.defs.PostView } describe('createFeedViewPostsSlices', () => { @@ -36,10 +36,7 @@ describe('createFeedViewPostsSlices', () => { reply: {root, parent}, opThreadPostIndex: 3, opThreadPostCount: 4, - } as app.bsky.feed.defs.FeedViewPost & { - opThreadPostIndex: number - opThreadPostCount: number - } + } satisfies app.bsky.feed.defs.FeedViewPost const [slice] = createFeedViewPostsSlices([feedPost]) diff --git a/src/lib/api/feed-manip.ts b/src/lib/api/feed-manip.ts index 167873c6b..f9fa82bea 100644 --- a/src/lib/api/feed-manip.ts +++ b/src/lib/api/feed-manip.ts @@ -5,15 +5,12 @@ import {FALLBACK_MARKER_POST} from './feed/home' import {type ReasonFeedSource} from './feed/types' export type FeedPostNumbering = Pick< - app.bsky.unspecced.defs.ThreadItemPost, + app.bsky.feed.defs.FeedViewPost, 'opThreadPostIndex' | 'opThreadPostCount' > export type ValidFeedPostNumbering = Required -// AppView adds these fields to feed responses ahead of their feed lexicon. -type FeedViewPost = app.bsky.feed.defs.FeedViewPost & FeedPostNumbering - function getPostNumbering( value: FeedPostNumbering, ): ValidFeedPostNumbering | undefined { @@ -36,7 +33,7 @@ function getPostNumbering( } function inferPostNumbering( - feedPost: FeedViewPost, + feedPost: app.bsky.feed.defs.FeedViewPost, position: 'parent' | 'root', ): ValidFeedPostNumbering | undefined { const postNumbering = getPostNumbering(feedPost) @@ -77,7 +74,7 @@ type AuthorContext = { export class FeedViewPostsSlice { _reactKey: string - _feedPost: FeedViewPost + _feedPost: app.bsky.feed.defs.FeedViewPost items: FeedSliceItem[] isIncompleteThread: boolean isFallbackMarker: boolean @@ -87,7 +84,7 @@ export class FeedViewPostsSlice { feedPostUri: string constructor( - feedPost: FeedViewPost, + feedPost: app.bsky.feed.defs.FeedViewPost, postNumberingByUri: Map, ) { const {post, reply, reason} = feedPost @@ -287,7 +284,7 @@ export class FeedViewPostsSlice { } export function createFeedViewPostsSlices( - feed: FeedViewPost[], + feed: app.bsky.feed.defs.FeedViewPost[], ): FeedViewPostsSlice[] { const postNumberingByUri = new Map() for (const item of feed) { @@ -310,7 +307,7 @@ export class FeedTuner { constructor(public tunerFns: FeedTunerFn[]) {} tune( - feed: FeedViewPost[], + feed: app.bsky.feed.defs.FeedViewPost[], {dryRun}: {dryRun: boolean} = { dryRun: false, }, -- knotmirror 0.0.1