Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/providers/lemmyv0/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ export function toPostView(v: LemmyV0.PostView): types.PostView {
read: v.read,
saved: v.saved,
subscribed: v.subscribed,
tags: [],
unread_comments: v.unread_comments,
};
}
Expand Down
4 changes: 4 additions & 0 deletions src/providers/piefed/compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ export function toPostView(
read: v.read,
saved: v.saved,
subscribed: toSubscribedType(v.subscribed),
tags: (v.flair_list ?? []).map((f) => ({
color: f.background_color,
name: f.flair_title,
})),
unread_comments: v.counts.comments,
};
}
Expand Down
19 changes: 19 additions & 0 deletions src/schemas/PostTag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { z } from "zod/v4-mini";

/**
* A tag attached to a post.
*
* - Lemmy v1: maps from `CommunityTag` (mod-curated, palette color slot like
* `"color03"`).
* - PieFed: maps from `CommunityFlair` applied to the post (hex `color`
* like `"#a91b9c"`).
* - Lemmy v0: not supported (empty array).
*
* `color` is opaque to threadiverse — consumers either render it directly
* (hex) or look it up in a palette (Lemmy v1 slot keys).
*/
export const PostTag = z.object({
color: z.optional(z.string()),
display_name: z.optional(z.string()),
name: z.string(),
});
2 changes: 2 additions & 0 deletions src/schemas/PostView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Community } from "./Community";
import { Person } from "./Person";
import { Post } from "./Post";
import { PostNotificationsMode } from "./PostNotificationsMode";
import { PostTag } from "./PostTag";
import { SubscribedType } from "./SubscribedType";
import { Vote } from "./Vote";

Expand All @@ -22,5 +23,6 @@ export const PostView = z.object({
read: z.boolean(),
saved: z.boolean(),
subscribed: SubscribedType,
tags: z.array(PostTag),
unread_comments: z.number(),
});
1 change: 1 addition & 0 deletions src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export * from "./Post";
export * from "./PostNotificationsMode";
export * from "./PostReport";
export * from "./PostReportView";
export * from "./PostTag";
export * from "./PostView";
export * from "./PrivateMessage";
export * from "./PrivateMessageView";
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type PostNotificationsMode = z.infer<
>;
export type PostReport = z.infer<typeof schemas.PostReport>;
export type PostReportView = z.infer<typeof schemas.PostReportView>;
export type PostTag = z.infer<typeof schemas.PostTag>;
export type PostView = z.infer<typeof schemas.PostView>;
export type PrivateMessage = z.infer<typeof schemas.PrivateMessage>;
export type PrivateMessageView = z.infer<typeof schemas.PrivateMessageView>;
Expand Down
Loading