diff --git a/packages/utils/feed/queries.ts b/packages/utils/feed/queries.ts index d38026ebcc..59fa68dae5 100644 --- a/packages/utils/feed/queries.ts +++ b/packages/utils/feed/queries.ts @@ -96,26 +96,24 @@ export const getPostCategory = ({ title, files, message, + gifs, }: NewPostFormValues): PostCategory => { - let category: PostCategory; + if (gifs?.length) return PostCategory.Picture; if (files?.length) { - if (files[0].fileType === "image") { - category = PostCategory.Picture; - } else if (files[0].fileType === "audio") { - category = PostCategory.Audio; - } else { - category = PostCategory.VideoNote; + switch (files[0].fileType) { + case "image": + return PostCategory.Picture; + case "audio": + return PostCategory.Audio; + default: + return PostCategory.VideoNote; } - } else if (title) { - category = PostCategory.Article; - } else if (message.startsWith("/question")) { - category = PostCategory.Question; - } else if (message.startsWith("/generate")) { - category = PostCategory.BriefForStableDiffusion; - } else { - category = PostCategory.Normal; } - return category; + if (title) return PostCategory.Article; + if (message.startsWith("/question")) return PostCategory.Question; + if (message.startsWith("/generate")) + return PostCategory.BriefForStableDiffusion; + return PostCategory.Normal; }; interface GeneratePostMetadataParams extends Omit {