Files
bsky-social-app/src/state/queries/usePostThread/utils.ts
T
Eric Bailey 5f586cbec0 Re-org
2025-06-11 11:39:52 -05:00

35 lines
963 B
TypeScript

import {
APP_BSKY_UNSPECCED,
AppBskyFeedThreadgate,
type AppBskyUnspeccedGetPostThreadV2,
} from '@atproto/api'
import {type PostThreadParams} from '#/state/queries/usePostThread/types'
import * as bsky from '#/types/bsky'
export function mapSortOptionsToSortID(sort: PostThreadParams['sort']) {
switch (sort) {
case 'hotness':
return APP_BSKY_UNSPECCED.GetPostThreadV2Hotness
case 'oldest':
return APP_BSKY_UNSPECCED.GetPostThreadV2Oldest
case 'newest':
return APP_BSKY_UNSPECCED.GetPostThreadV2Newest
case 'most-likes':
return APP_BSKY_UNSPECCED.GetPostThreadV2MostLikes
default:
return APP_BSKY_UNSPECCED.GetPostThreadV2Hotness
}
}
export function getThreadgateRecord(
view: AppBskyUnspeccedGetPostThreadV2.OutputSchema['threadgate'],
) {
return bsky.dangerousIsType<AppBskyFeedThreadgate.Record>(
view?.record,
AppBskyFeedThreadgate.isRecord,
)
? view?.record
: undefined
}