diff --git a/.changeset/lazy-moons-relate.md b/.changeset/lazy-moons-relate.md new file mode 100644 index 00000000000..b314453a6f1 --- /dev/null +++ b/.changeset/lazy-moons-relate.md @@ -0,0 +1,5 @@ +--- +'@atproto/api': patch +--- + +Improve the types of the thread and feed preferences APIs diff --git a/packages/api/src/bsky-agent.ts b/packages/api/src/bsky-agent.ts index 2ba8d7bf48c..37b8d9c3620 100644 --- a/packages/api/src/bsky-agent.ts +++ b/packages/api/src/bsky-agent.ts @@ -6,7 +6,12 @@ import { AppBskyActorDefs, ComAtprotoRepoPutRecord, } from './client' -import { BskyPreferences, BskyLabelPreference } from './types' +import { + BskyPreferences, + BskyLabelPreference, + BskyFeedViewPreference, + BskyThreadViewPreference, +} from './types' const FEED_VIEW_PREF_DEFAULTS = { hideReplies: false, @@ -439,10 +444,7 @@ export class BskyAgent extends AtpAgent { }) } - async setFeedViewPrefs( - feed: string, - pref: Omit, - ) { + async setFeedViewPrefs(feed: string, pref: Partial) { await updatePreferences(this, (prefs: AppBskyActorDefs.Preferences) => { const existing = prefs.findLast( (pref) => @@ -461,9 +463,7 @@ export class BskyAgent extends AtpAgent { }) } - async setThreadViewPrefs( - pref: Omit, - ) { + async setThreadViewPrefs(pref: Partial) { await updatePreferences(this, (prefs: AppBskyActorDefs.Preferences) => { const existing = prefs.findLast( (pref) => diff --git a/packages/api/src/types.ts b/packages/api/src/types.ts index 985ceb44c31..10d0bbd90fe 100644 --- a/packages/api/src/types.ts +++ b/packages/api/src/types.ts @@ -1,5 +1,4 @@ import { LabelPreference } from './moderation/types' -import { AppBskyActorDefs } from './client' /** * Used by the PersistSessionHandler to indicate what change occurred @@ -81,15 +80,37 @@ export type BskyLabelPreference = LabelPreference | 'show' // TEMP we need to permanently convert 'show' to 'ignore', for now we manually convert -prf /** - * Bluesky preferences object + * Bluesky feed view preferences + */ + +export interface BskyFeedViewPreference { + hideReplies: boolean + hideRepliesByUnfollowed: boolean + hideRepliesByLikeCount: number + hideReposts: boolean + hideQuotePosts: boolean + [key: string]: any +} + +/** + * Bluesky thread view preferences + */ +export interface BskyThreadViewPreference { + sort: string + prioritizeFollowedUsers: boolean + [key: string]: any +} + +/** + * Bluesky preferences */ export interface BskyPreferences { feeds: { saved?: string[] pinned?: string[] } - feedViewPrefs: Record> - threadViewPrefs: Omit + feedViewPrefs: Record + threadViewPrefs: BskyThreadViewPreference adultContentEnabled: boolean contentLabels: Record birthDate: Date | undefined