Integrate postgates into ThreadgateEditor dialog
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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'},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user