Skip to content

Commit

Permalink
chore(lauchpad): Use ArticleMarkdown types
Browse files Browse the repository at this point in the history
  • Loading branch information
WaDadidou committed Dec 20, 2024
1 parent 1978419 commit 0aae569
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions packages/screens/FeedNewArticle/FeedNewArticleScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -56,7 +56,7 @@ import {
CustomLatLngExpression,
NewArticleFormValues,
PostCategory,
SocialFeedArticleMetadata,
SocialFeedArticleMarkdownMetadata,
} from "@/utils/types/feed";

export const FeedNewArticleScreen: ScreenFC<"FeedNewArticle"> = () => {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -182,7 +182,7 @@ export const FeedNewArticleScreen: ScreenFC<"FeedNewArticle"> = () => {
)[0]
: undefined;

const metadata = generateArticleMetadata({
const metadata = generateArticleMarkdownMetadata({
...formValues,
thumbnailImage: remoteThumbnail,
gifs: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
OnPressReplyType,
PostCategory,
ReplyToType,
ZodSocialFeedArticleMetadata,
ZodSocialFeedArticleMarkdownMetadata,
} from "@/utils/types/feed";

const contentPaddingHorizontal = layout.spacing_x2;
Expand Down Expand Up @@ -96,7 +96,7 @@ export const FeedPostArticleMarkdownView: FC<{
const isNextPageAvailable = useSharedValue(hasNextPage);

const articleMetadata = zodTryParseJSON(
ZodSocialFeedArticleMetadata,
ZodSocialFeedArticleMarkdownMetadata,
post.metadata,
);
const message = articleMetadata?.message;
Expand Down
12 changes: 6 additions & 6 deletions packages/utils/feed/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
NewArticleFormValues,
NewPostFormValues,
PostCategory,
SocialFeedArticleMetadata,
SocialFeedPostMetadata,
SocialFeedArticleMarkdownMetadata,
SocialFeedPostMetadata, ZodSocialFeedArticleMarkdownMetadata,

Check failure on line 18 in packages/utils/feed/queries.ts

View workflow job for this annotation

GitHub Actions / check-js

Insert `⏎·`
ZodSocialFeedArticleMetadata,

Check failure on line 19 in packages/utils/feed/queries.ts

View workflow job for this annotation

GitHub Actions / check-js

'ZodSocialFeedArticleMetadata' is defined but never used
ZodSocialFeedPostMetadata,
} from "../types/feed";
Expand Down Expand Up @@ -112,7 +112,7 @@ interface GeneratePostMetadataParams extends Omit<NewPostFormValues, "files"> {
location?: CustomLatLngExpression;
}

interface GenerateArticleMetadataParams
interface GenerateArticleMarkdownMetadataParams
extends Omit<
NewArticleFormValues,
"files" | "thumbnailImage" | "coverImage"
Expand Down Expand Up @@ -147,7 +147,7 @@ export const generatePostMetadata = ({
return m;
};

export const generateArticleMetadata = ({
export const generateArticleMarkdownMetadata = ({
title,
message,
files,
Expand All @@ -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,
Expand Down
16 changes: 14 additions & 2 deletions packages/utils/types/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 0aae569

Please sign in to comment.