Merge branch 'dev' into hotfix/posting

This commit is contained in:
Untone 2024-02-03 00:22:11 +03:00
commit 5f47bf161c
3 changed files with 11 additions and 12 deletions

View File

@ -122,11 +122,10 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
const updateShout = async (formToUpdate: ShoutForm, { publish }: { publish: boolean }) => {
return await apiClient.updateArticle({
shoutId: formToUpdate.shoutId,
shoutInput: {
shout_id: formToUpdate.shoutId,
shout_input: {
...formToUpdate,
topics: formToUpdate.selectedTopics.map((topic) => topic2topicInput(topic)), // NOTE: first is main
media: formToUpdate.media,
cover: formToUpdate.coverImageUrl,
},
publish,
@ -196,10 +195,10 @@ export const EditorProvider = (props: { children: JSX.Element }) => {
}
}
const publishShoutById = async (shoutId: number) => {
const publishShoutById = async (shout_id: number) => {
try {
await apiClient.updateArticle({
shoutId,
shout_id,
publish: true,
})

View File

@ -150,16 +150,16 @@ export const apiClient = {
return response.data.create_shout.shout
},
updateArticle: async ({
shoutId,
shoutInput,
shout_id,
shout_input,
publish,
}: {
shoutId: number
shoutInput?: ShoutInput
shout_id: number
shout_input?: ShoutInput
publish: boolean
}): Promise<Shout> => {
const response = await apiClient.private
.mutation(updateArticle, { shoutId, shoutInput, publish })
.mutation(updateArticle, { shout_id, shout_input, publish })
.toPromise()
console.debug('[graphql.client.core] updateArticle:', response.data)
return response.data.update_shout.shout

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core'
export default gql`
mutation UpdateShoutMutation($shoutId: Int!, $shoutInput: ShoutInput, $publish: Boolean) {
update_shout(shout_id: $shoutId, shout_input: $shoutInput, publish: $publish) {
mutation UpdateShoutMutation($shout_id: Int!, $shout_input: ShoutInput, $publish: Boolean) {
update_shout(shout_id: $shout_id, shout_input: $shout_input, publish: $publish) {
error
shout {
id