Skip to content

Commit

Permalink
fix: simplify getPostCategory
Browse files Browse the repository at this point in the history
Co-authored-by: 6h057 <[email protected]>
  • Loading branch information
WaDadidou and omarsy authored Sep 18, 2024
1 parent 168509b commit 2a1636e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/utils/feed/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,33 @@ export const getPostCategory = ({
}: NewPostFormValues): PostCategory => {
let category: PostCategory;
if (gifs?.length) {
return PostCategory.Picture;
}

if (files?.length) {
switch (files[0].fileType) {
case "image":
return PostCategory.Picture;
case "audio":
return PostCategory.Audio;
default:
return PostCategory.VideoNote;
}
}

if (title) {
return PostCategory.Article;
}

if (message.startsWith("/question")) {
return PostCategory.Question;
}

if (message.startsWith("/generate")) {
return PostCategory.BriefForStableDiffusion;
}

return PostCategory.Normal;
category = PostCategory.Picture;
} else if (files?.length) {
if (files[0].fileType === "image") {
Expand Down

0 comments on commit 2a1636e

Please sign in to comment.