Skip to content

Commit

Permalink
feat: mark gifs as PostCategory.Picture (#1278)
Browse files Browse the repository at this point in the history
* considers post with gifs as PostCategory.Picture

* simplify getPostCategory
  • Loading branch information
WaDadidou authored Sep 18, 2024
1 parent 9cca3b1 commit 2c9f212
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions packages/utils/feed/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<NewPostFormValues, "files"> {
Expand Down

0 comments on commit 2c9f212

Please sign in to comment.