diff --git a/packages/components/socialFeed/SocialCard/cards/SocialArticleMarkdownCard.tsx b/packages/components/socialFeed/SocialCard/cards/SocialArticleMarkdownCard.tsx index 24c066026..f0879fe58 100644 --- a/packages/components/socialFeed/SocialCard/cards/SocialArticleMarkdownCard.tsx +++ b/packages/components/socialFeed/SocialCard/cards/SocialArticleMarkdownCard.tsx @@ -31,7 +31,7 @@ import { RESPONSIVE_BREAKPOINT_S, SOCIAL_FEED_BREAKPOINT_M, } from "@/utils/style/layout"; -import { ZodSocialFeedArticleMetadata } from "@/utils/types/feed"; +import { ZodSocialFeedArticleMarkdownMetadata } from "@/utils/types/feed"; const ARTICLE_CARD_PADDING_VERTICAL = layout.spacing_x2; const ARTICLE_CARD_PADDING_HORIZONTAL = layout.spacing_x2_5; @@ -57,7 +57,7 @@ export const SocialArticleMarkdownCard: FC<{ windowWidth < RESPONSIVE_BREAKPOINT_S ? 0 : SOCIAl_CARD_BORDER_RADIUS; const metadata = zodTryParseJSON( - ZodSocialFeedArticleMetadata, + ZodSocialFeedArticleMarkdownMetadata, localPost.metadata, ); const thumbnailImage = metadata?.thumbnailImage; diff --git a/packages/screens/FeedNewArticle/FeedNewArticleScreen.tsx b/packages/screens/FeedNewArticle/FeedNewArticleScreen.tsx index 7e0648a87..46a7309ba 100644 --- a/packages/screens/FeedNewArticle/FeedNewArticleScreen.tsx +++ b/packages/screens/FeedNewArticle/FeedNewArticleScreen.tsx @@ -34,7 +34,7 @@ import { ArticleContentEditor } from "@/screens/FeedNewArticle/components/Articl import { NewArticleLocationButton } from "@/screens/FeedNewArticle/components/NewArticleLocationButton"; import { selectNFTStorageAPI } from "@/store/slices/settings"; import { feedPostingStep, FeedPostingStepId } from "@/utils/feed/posting"; -import { generateArticleMetadata } from "@/utils/feed/queries"; +import { generateArticleMarkdownMetadata } from "@/utils/feed/queries"; import { generateIpfsKey } from "@/utils/ipfs"; import { IMAGE_MIME_TYPES } from "@/utils/mime"; import { ScreenFC, useAppNavigation } from "@/utils/navigation"; @@ -56,7 +56,7 @@ import { CustomLatLngExpression, NewArticleFormValues, PostCategory, - SocialFeedArticleMetadata, + SocialFeedArticleMarkdownMetadata, } from "@/utils/types/feed"; export const FeedNewArticleScreen: ScreenFC<"FeedNewArticle"> = () => { @@ -123,7 +123,7 @@ export const FeedNewArticleScreen: ScreenFC<"FeedNewArticle"> = () => { }); const formValues = newArticleForm.watch(); - const previewMetadata: SocialFeedArticleMetadata = { + const previewMetadata: SocialFeedArticleMarkdownMetadata = { title: formValues.title, shortDescription: formValues.shortDescription || "", thumbnailImage: formValues.thumbnailImage, @@ -182,7 +182,7 @@ export const FeedNewArticleScreen: ScreenFC<"FeedNewArticle"> = () => { )[0] : undefined; - const metadata = generateArticleMetadata({ + const metadata = generateArticleMarkdownMetadata({ ...formValues, thumbnailImage: remoteThumbnail, gifs: [], diff --git a/packages/screens/FeedPostView/components/FeedPostArticleMarkdownView.tsx b/packages/screens/FeedPostView/components/FeedPostArticleMarkdownView.tsx index 6566a3d2b..2c4b59d72 100644 --- a/packages/screens/FeedPostView/components/FeedPostArticleMarkdownView.tsx +++ b/packages/screens/FeedPostView/components/FeedPostArticleMarkdownView.tsx @@ -50,7 +50,7 @@ import { OnPressReplyType, PostCategory, ReplyToType, - ZodSocialFeedArticleMetadata, + ZodSocialFeedArticleMarkdownMetadata, } from "@/utils/types/feed"; const contentPaddingHorizontal = layout.spacing_x2; @@ -96,7 +96,7 @@ export const FeedPostArticleMarkdownView: FC<{ const isNextPageAvailable = useSharedValue(hasNextPage); const articleMetadata = zodTryParseJSON( - ZodSocialFeedArticleMetadata, + ZodSocialFeedArticleMarkdownMetadata, post.metadata, ); const message = articleMetadata?.message; diff --git a/packages/utils/feed/queries.ts b/packages/utils/feed/queries.ts index b9f6897f6..b7e249964 100644 --- a/packages/utils/feed/queries.ts +++ b/packages/utils/feed/queries.ts @@ -14,8 +14,8 @@ import { NewArticleFormValues, NewPostFormValues, PostCategory, - SocialFeedArticleMetadata, - SocialFeedPostMetadata, + SocialFeedArticleMarkdownMetadata, + SocialFeedPostMetadata, ZodSocialFeedArticleMarkdownMetadata, ZodSocialFeedArticleMetadata, ZodSocialFeedPostMetadata, } from "../types/feed"; @@ -112,7 +112,7 @@ interface GeneratePostMetadataParams extends Omit { location?: CustomLatLngExpression; } -interface GenerateArticleMetadataParams +interface GenerateArticleMarkdownMetadataParams extends Omit< NewArticleFormValues, "files" | "thumbnailImage" | "coverImage" @@ -147,7 +147,7 @@ export const generatePostMetadata = ({ return m; }; -export const generateArticleMetadata = ({ +export const generateArticleMarkdownMetadata = ({ title, message, files, @@ -159,8 +159,8 @@ export const generateArticleMetadata = ({ coverImage, shortDescription, location, -}: GenerateArticleMetadataParams): SocialFeedArticleMetadata => { - const m = ZodSocialFeedArticleMetadata.parse({ +}: GenerateArticleMarkdownMetadataParams): SocialFeedArticleMarkdownMetadata => { + const m = ZodSocialFeedArticleMarkdownMetadata.parse({ title, message, files, diff --git a/packages/utils/types/feed.ts b/packages/utils/types/feed.ts index 7a61b457b..68c4a026d 100644 --- a/packages/utils/types/feed.ts +++ b/packages/utils/types/feed.ts @@ -107,8 +107,20 @@ export const ZodSocialFeedArticleMetadata = z.object({ mentions: z.array(z.string()), ...zodSocialFeedCommonMetadata.shape, }); -export type SocialFeedArticleMetadata = z.infer< - typeof ZodSocialFeedArticleMetadata + +export const ZodSocialFeedArticleMarkdownMetadata = z.object({ + shortDescription: z.string(), + thumbnailImage: ZodRemoteFileData.optional(), + coverImage: ZodRemoteFileData.optional(), + message: z.string(), + files: MaybeFiles.optional(), + gifs: z.array(z.string()).optional(), + hashtags: z.array(z.string()), + mentions: z.array(z.string()), + ...zodSocialFeedCommonMetadata.shape, +}); +export type SocialFeedArticleMarkdownMetadata = z.infer< + typeof ZodSocialFeedArticleMarkdownMetadata >; export const ZodSocialFeedTrackMetadata = z.object({