Merge branch 'main' into app-2067

This commit is contained in:
vineyardbovines
2026-04-17 09:02:19 -04:00
128 changed files with 7775 additions and 2556 deletions
@@ -0,0 +1,37 @@
import {type ChatBskyGroupCreateGroup} from '@atproto/api'
import {useMutation, useQueryClient} from '@tanstack/react-query'
import {DM_SERVICE_HEADERS} from '#/lib/constants'
import {logger} from '#/logger'
import {useAgent} from '#/state/session'
import {precacheConvoQuery} from './conversation'
export function useCreateGroupChat({
onSuccess,
onError,
}: {
onSuccess?: (data: ChatBskyGroupCreateGroup.OutputSchema) => void
onError?: (error: Error) => void
}) {
const queryClient = useQueryClient()
const agent = useAgent()
return useMutation({
mutationFn: async ({name, members}: {name: string; members: string[]}) => {
const {data} = await agent.chat.bsky.group.createGroup(
{name, members},
{headers: DM_SERVICE_HEADERS},
)
return data
},
onSuccess: data => {
precacheConvoQuery(queryClient, data.convo)
onSuccess?.(data)
},
onError: error => {
logger.error(error)
onError?.(error)
},
})
}
@@ -24,17 +24,20 @@ export const RQKEY_ROOT = 'convo-list'
export const RQKEY = (
status: 'accepted' | 'request' | 'all',
readState: 'all' | 'unread' = 'all',
) => [RQKEY_ROOT, status, readState]
kind: 'all' | 'group' | 'direct' = 'all',
) => [RQKEY_ROOT, status, readState, kind]
type RQPageParam = string | undefined
export function useListConvosQuery({
enabled,
status,
readState = 'all',
kind = 'all',
}: {
enabled?: boolean
status?: 'request' | 'accepted'
readState?: 'all' | 'unread'
kind?: 'all' | 'group' | 'direct'
} = {}) {
const agent = useAgent()
@@ -47,6 +50,7 @@ export function useListConvosQuery({
limit: 20,
cursor: pageParam,
readState: readState === 'unread' ? 'unread' : undefined,
kind: kind === 'all' ? undefined : kind,
status,
},
{headers: DM_SERVICE_HEADERS},
@@ -31,13 +31,13 @@ export function useMuteConvo(
mutationFn: async ({mute}: {mute: boolean}) => {
if (!convoId) throw new Error('No convoId provided')
if (mute) {
const {data} = await agent.api.chat.bsky.convo.muteConvo(
const {data} = await agent.chat.bsky.convo.muteConvo(
{convoId},
{headers: DM_SERVICE_HEADERS, encoding: 'application/json'},
)
return data
} else {
const {data} = await agent.api.chat.bsky.convo.unmuteConvo(
const {data} = await agent.chat.bsky.convo.unmuteConvo(
{convoId},
{headers: DM_SERVICE_HEADERS, encoding: 'application/json'},
)
+12 -7
View File
@@ -143,7 +143,8 @@ export type Gif = {
/**
* A dictionary with a content format as the key and a Media Object as the value.
*/
media_formats: Record<ContentFormats, MediaObject>
media_formats: Record<BaseContentFormats, MediaObject> &
Partial<Record<VideoContentFormats, MediaObject>>
/**
* An array of tags for the post
*/
@@ -198,16 +199,20 @@ type MediaObject = {
size: number
}
type ContentFormats =
type BaseContentFormats =
| 'preview'
| 'gif'
// | 'mediumgif'
| 'tinygif'
// | 'nanogif'
// | 'mp4'
// | 'loopedmp4'
// | 'tinymp4'
// | 'nanomp4'
// | 'webm'
type VideoContentFormats =
| 'mp4'
// | 'loopedmp4'
// | 'tinymp4'
// | 'nanomp4'
| 'webm'
// | 'tinywebm'
// | 'nanowebm'
type ContentFormats = BaseContentFormats | VideoContentFormats
@@ -19,9 +19,9 @@ export type QueryProps = {
export const getSuggestedUsersForDiscoverQueryKeyRoot =
'unspecced-suggested-users-for-explore'
export const createGetSuggestedUsersForDiscoverQueryKey = (
props: QueryProps,
) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit]
export const createGetSuggestedUsersForDiscoverQueryKey = (props: {
limit?: number
}) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit]
export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
const agent = useAgent()
@@ -29,7 +29,7 @@ export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
return useQuery({
staleTime: STALE.MINUTES.THREE,
queryKey: createGetSuggestedUsersForDiscoverQueryKey(props),
queryKey: createGetSuggestedUsersForDiscoverQueryKey({limit: props.limit}),
queryFn: async () => {
const contentLangs = getContentLanguages().join(',')
const userInterests = aggregateUserInterests(preferences)
@@ -16,21 +16,27 @@ import {useAgent} from '#/state/session'
export type QueryProps = {
category?: string | null
limit?: number
enabled?: boolean
}
export const getSuggestedUsersForSeeMoreQueryKeyRoot =
'unspecced-suggested-users-for-explore'
export const createGetSuggestedUsersForSeeMoreQueryKey = (
props: QueryProps,
) => [getSuggestedUsersForSeeMoreQueryKeyRoot, props.category, props.limit]
export const createGetSuggestedUsersForSeeMoreQueryKey = (props: {
category?: string | null
limit?: number
}) => [getSuggestedUsersForSeeMoreQueryKeyRoot, props.category, props.limit]
export function useGetSuggestedUsersForSeeMoreQuery(props: QueryProps = {}) {
const agent = useAgent()
const {data: preferences} = usePreferencesQuery()
return useQuery({
enabled: props.enabled ?? true,
staleTime: STALE.MINUTES.THREE,
queryKey: createGetSuggestedUsersForSeeMoreQueryKey(props),
queryKey: createGetSuggestedUsersForSeeMoreQueryKey({
category: props.category,
limit: props.limit,
}),
queryFn: async () => {
const contentLangs = getContentLanguages().join(',')
const userInterests = aggregateUserInterests(preferences)