Skip to content

Commit

Permalink
Add hotness as a default thread sort option (bluesky-social#3082)
Browse files Browse the repository at this point in the history
* Add hotness as a thread sorting option

* Changeset
  • Loading branch information
gaearon authored Nov 23, 2024
1 parent 0dff612 commit a3ce23c
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 42 deletions.
8 changes: 8 additions & 0 deletions .changeset/fluffy-otters-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@atproto/ozone": patch
"@atproto/bsky": patch
"@atproto/api": patch
"@atproto/pds": patch
---

Add hotness as a thread sorting option
2 changes: 1 addition & 1 deletion lexicons/app/bsky/actor/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
"sort": {
"type": "string",
"description": "Sorting mode for threads.",
"knownValues": ["oldest", "newest", "most-likes", "random"]
"knownValues": ["oldest", "newest", "most-likes", "random", "hotness"]
},
"prioritizeFollowedUsers": {
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const FEED_VIEW_PREF_DEFAULTS = {
}

const THREAD_VIEW_PREF_DEFAULTS = {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
}

Expand Down
13 changes: 9 additions & 4 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4490,7 +4490,13 @@ export const schemaDict = {
sort: {
type: 'string',
description: 'Sorting mode for threads.',
knownValues: ['oldest', 'newest', 'most-likes', 'random'],
knownValues: [
'oldest',
'newest',
'most-likes',
'random',
'hotness',
],
},
prioritizeFollowedUsers: {
type: 'boolean',
Expand Down Expand Up @@ -13483,9 +13489,8 @@ export const schemaDict = {
},
},
},
} as const satisfies Record<string, LexiconDoc>

export const schemas = Object.values(schemaDict)
}
export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[]
export const lexicons: Lexicons = new Lexicons(schemas)
export const ids = {
ComAtprotoAdminDefs: 'com.atproto.admin.defs',
Expand Down
8 changes: 7 additions & 1 deletion packages/api/src/client/types/app/bsky/actor/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,13 @@ export function validateFeedViewPref(v: unknown): ValidationResult {

export interface ThreadViewPref {
/** Sorting mode for threads. */
sort?: 'oldest' | 'newest' | 'most-likes' | 'random' | (string & {})
sort?:
| 'oldest'
| 'newest'
| 'most-likes'
| 'random'
| 'hotness'
| (string & {})
/** Show followed users at the top of all replies. */
prioritizeFollowedUsers?: boolean
[k: string]: unknown
Expand Down
32 changes: 16 additions & 16 deletions packages/api/tests/atp-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -309,7 +309,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -351,7 +351,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -439,7 +439,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -488,7 +488,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -537,7 +537,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -586,7 +586,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -635,7 +635,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -684,7 +684,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -739,7 +739,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -788,7 +788,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -837,7 +837,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -886,7 +886,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -935,7 +935,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down Expand Up @@ -991,7 +991,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
interests: {
Expand Down
8 changes: 4 additions & 4 deletions packages/api/tests/moderation-prefs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('agent', () => {
},
threadViewPrefs: {
prioritizeFollowedUsers: true,
sort: 'oldest',
sort: 'hotness',
},
bskyAppState: {
activeProgressGuide: undefined,
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
bskyAppState: {
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
bskyAppState: {
Expand Down Expand Up @@ -220,7 +220,7 @@ describe('agent', () => {
},
},
threadViewPrefs: {
sort: 'oldest',
sort: 'hotness',
prioritizeFollowedUsers: true,
},
bskyAppState: {
Expand Down
13 changes: 9 additions & 4 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4490,7 +4490,13 @@ export const schemaDict = {
sort: {
type: 'string',
description: 'Sorting mode for threads.',
knownValues: ['oldest', 'newest', 'most-likes', 'random'],
knownValues: [
'oldest',
'newest',
'most-likes',
'random',
'hotness',
],
},
prioritizeFollowedUsers: {
type: 'boolean',
Expand Down Expand Up @@ -10722,9 +10728,8 @@ export const schemaDict = {
},
},
},
} as const satisfies Record<string, LexiconDoc>

export const schemas = Object.values(schemaDict)
}
export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[]
export const lexicons: Lexicons = new Lexicons(schemas)
export const ids = {
ComAtprotoAdminDefs: 'com.atproto.admin.defs',
Expand Down
8 changes: 7 additions & 1 deletion packages/bsky/src/lexicon/types/app/bsky/actor/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,13 @@ export function validateFeedViewPref(v: unknown): ValidationResult {

export interface ThreadViewPref {
/** Sorting mode for threads. */
sort?: 'oldest' | 'newest' | 'most-likes' | 'random' | (string & {})
sort?:
| 'oldest'
| 'newest'
| 'most-likes'
| 'random'
| 'hotness'
| (string & {})
/** Show followed users at the top of all replies. */
prioritizeFollowedUsers?: boolean
[k: string]: unknown
Expand Down
13 changes: 9 additions & 4 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4490,7 +4490,13 @@ export const schemaDict = {
sort: {
type: 'string',
description: 'Sorting mode for threads.',
knownValues: ['oldest', 'newest', 'most-likes', 'random'],
knownValues: [
'oldest',
'newest',
'most-likes',
'random',
'hotness',
],
},
prioritizeFollowedUsers: {
type: 'boolean',
Expand Down Expand Up @@ -13483,9 +13489,8 @@ export const schemaDict = {
},
},
},
} as const satisfies Record<string, LexiconDoc>

export const schemas = Object.values(schemaDict)
}
export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[]
export const lexicons: Lexicons = new Lexicons(schemas)
export const ids = {
ComAtprotoAdminDefs: 'com.atproto.admin.defs',
Expand Down
8 changes: 7 additions & 1 deletion packages/ozone/src/lexicon/types/app/bsky/actor/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,13 @@ export function validateFeedViewPref(v: unknown): ValidationResult {

export interface ThreadViewPref {
/** Sorting mode for threads. */
sort?: 'oldest' | 'newest' | 'most-likes' | 'random' | (string & {})
sort?:
| 'oldest'
| 'newest'
| 'most-likes'
| 'random'
| 'hotness'
| (string & {})
/** Show followed users at the top of all replies. */
prioritizeFollowedUsers?: boolean
[k: string]: unknown
Expand Down
13 changes: 9 additions & 4 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4490,7 +4490,13 @@ export const schemaDict = {
sort: {
type: 'string',
description: 'Sorting mode for threads.',
knownValues: ['oldest', 'newest', 'most-likes', 'random'],
knownValues: [
'oldest',
'newest',
'most-likes',
'random',
'hotness',
],
},
prioritizeFollowedUsers: {
type: 'boolean',
Expand Down Expand Up @@ -13483,9 +13489,8 @@ export const schemaDict = {
},
},
},
} as const satisfies Record<string, LexiconDoc>

export const schemas = Object.values(schemaDict)
}
export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[]
export const lexicons: Lexicons = new Lexicons(schemas)
export const ids = {
ComAtprotoAdminDefs: 'com.atproto.admin.defs',
Expand Down
8 changes: 7 additions & 1 deletion packages/pds/src/lexicon/types/app/bsky/actor/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,13 @@ export function validateFeedViewPref(v: unknown): ValidationResult {

export interface ThreadViewPref {
/** Sorting mode for threads. */
sort?: 'oldest' | 'newest' | 'most-likes' | 'random' | (string & {})
sort?:
| 'oldest'
| 'newest'
| 'most-likes'
| 'random'
| 'hotness'
| (string & {})
/** Show followed users at the top of all replies. */
prioritizeFollowedUsers?: boolean
[k: string]: unknown
Expand Down

0 comments on commit a3ce23c

Please sign in to comment.