Integrate postgates into ThreadgateEditor dialog

This commit is contained in:
Eric Bailey
2024-08-09 15:04:01 -05:00
parent f9e988c5fb
commit 26e7d31557
9 changed files with 424 additions and 167 deletions
+25
View File
@@ -135,6 +135,31 @@ export function usePostgateQuery({postUri}: {postUri: string}) {
})
}
export function useWritePostgateMutation() {
const agent = useAgent()
const queryClient = useQueryClient()
return useMutation({
mutationFn: async ({
postUri,
postgate,
}: {
postUri: string
postgate: AppBskyFeedPostgate.Record
}) => {
return writePostgateRecord({
agent,
postUri,
postgate,
})
},
onSuccess(_, {postUri}) {
queryClient.invalidateQueries({
queryKey: [createPostgateQueryKey(postUri)],
})
},
})
}
export function useToggleQuoteDetachmentMutation() {
const agent = useAgent()
const queryClient = useQueryClient()
+7 -5
View File
@@ -10,12 +10,10 @@ import {ViewRemoved} from '@atproto/api/dist/client/types/app/bsky/embed/record'
export const POSTGATE_COLLECTION = 'app.bsky.feed.postgate'
export function createPostgateRecord(
postgate: Partial<AppBskyFeedPostgate.Record>,
postgate: Partial<AppBskyFeedPostgate.Record> & {
post: AppBskyFeedPostgate.Record['post']
},
): AppBskyFeedPostgate.Record {
if (!postgate.post) {
throw new Error(`Cannot create a postgate record without a post URI`)
}
return {
$type: POSTGATE_COLLECTION,
createdAt: new Date().toISOString(),
@@ -190,3 +188,7 @@ export function getMaybeDetachedQuoteEmbed({
}
}
}
export const embeddingRules = {
disableRule: {$type: 'app.bsky.feed.postgate#disableRule'},
}