From 2c9f212bdaea70e02bacb14cd79c79208d20bda0 Mon Sep 17 00:00:00 2001 From: WaDadidou <50441633+WaDadidou@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:09:44 -0400 Subject: [PATCH] feat: mark gifs as PostCategory.Picture (#1278) * considers post with gifs as PostCategory.Picture * simplify getPostCategory --- packages/utils/feed/queries.ts | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) 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 {