Skip to content

Commit fa38cc9

Browse files
authored
fix: prevent empty image object from being sent in freeform post creation (#5874)
1 parent c693e5f commit fa38cc9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/shared/src/graphql/posts.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,12 +960,17 @@ export type CreatePostInMultipleSourcesResponse = Array<{
960960
export const createPostInMultipleSources = async (
961961
variables: CreatePostInMultipleSourcesArgs,
962962
) => {
963+
const { image, ...rest } = variables;
964+
const sanitized = {
965+
...rest,
966+
...(image instanceof File && image.size > 0 ? { image } : {}),
967+
};
963968
const res = await gqlClient.request<
964969
{
965970
createPostInMultipleSources: CreatePostInMultipleSourcesResponse;
966971
},
967972
CreatePostInMultipleSourcesArgs
968-
>(CREATE_POST_IN_MULTIPLE_SOURCES, variables);
973+
>(CREATE_POST_IN_MULTIPLE_SOURCES, sanitized);
969974
return res.createPostInMultipleSources;
970975
};
971976

packages/webapp/pages/squads/create.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,11 @@ function CreatePost(): ReactElement {
182182
return;
183183
}
184184

185-
const { options, ...args } = params;
185+
const { options, image, ...args } = params;
186186

187187
await onCreate({
188188
...args,
189+
...(image instanceof File && image.size > 0 && { image }),
189190
...(options?.length && {
190191
options: options.map((text, order) => ({
191192
text,

0 commit comments

Comments
 (0)