From 7f9d8c6f864175e6e4ee012b0c16680f4631cca6 Mon Sep 17 00:00:00 2001 From: Xylight Date: Sun, 21 Sep 2025 20:51:48 -0700 Subject: [PATCH] fix: piefed page cursor types won't work --- bun.lockb | Bin 186370 -> 186370 bytes src/lib/client/piefed/rewrite.ts | 4 +- src/lib/client/piefed/schema.d.ts | 520 ++++++++++++++++-- .../client/types/schemas/GetPostsResponse.ts | 2 +- src/lib/lemmy/feeds/feed.svelte.ts | 8 +- src/routes/+page.ts | 13 +- src/routes/c/[name]/+page.svelte | 6 +- src/routes/c/[name]/+page.ts | 2 +- src/routes/f/[id]/+page.svelte | 2 +- src/routes/f/[id]/+page.ts | 7 +- src/routes/topic/[id]/+page.ts | 6 +- 11 files changed, 504 insertions(+), 66 deletions(-) diff --git a/bun.lockb b/bun.lockb index ffd0b54b86f27732a80f776ab6541bb851228bd6..5b2b015c3d9264001f04c7d72d827299d1e32f20 100755 GIT binary patch delta 396 zcmZqLz}>WgyI~7s``dIQ1_mhx1_mJphK7BDlj~pT$y#zS##!hY=mBMPfHHhQ876Vf z2FnWjML-!tJ!6oJ6;Or?C?m!iDeEWOd=e;Qsb_4aXTabB)pPF9$*T7qSI+}wjPwkr zzkADQEDP3J2UH*d)H=m$@!>^b_a_1s7z3@doNo7yQJlrZNY7|`YO3@`}R4YT0=dM+9@9x z8zq4bC@Id#OaeN>ZT{U=i^O;T04gxjvzV^;kx|kDXcPm36B7f2Akc+}iWls-Ztrs$ vsK7$c!~_@)!9W=vpv(emqd%%`XRX0z8|axBPOtySD8Xc8uzlu7#>{5``v7nt delta 396 zcmZqLz}>WgyI~7s``dIw1_mhx1_mJphK7BDlj~pT$y#zS##!hY=mBMPfHHhQ876Vf z2FnWjML-!tJtI9!1_mpj3>Q#Fj5Si$Pqz6aP{vZv2&j$01*+%Vp_5hbJFcDw${6Vx zOn>*5(O4F&wGOC20;qM0*W$yA!tPH5Dli6GXEELG9iuplp}C&n^vHLNKGGHp3?G3? z1%OIBGxYo~{WS>zDm4JwZ!rD9J4SCNBa7+0?-?bT4S@oh?-|d?n&=rDFccJ}mXu_s z7Tt+62->8*vlncu`w|4f`KwTK$!*BMt@Y>&RT=bHqbM+m|p*pQG&_PWc$pIjG4~> export interface components { @@ -3696,12 +4049,16 @@ export interface components { /** Format: html */ about_html?: string /** Format: url */ - avatar?: string + avatar?: string | null /** Format: url */ - banner?: string + banner?: string | null flair?: string - published: string - title?: string + /** + * Format: datetime + * @example 2025-06-07T02:29:07.980084Z + */ + published?: string + title?: string | null } PersonView: { activity_alert: boolean @@ -3762,12 +4119,12 @@ export interface components { title: string banned?: boolean /** Format: url */ - banner?: string + banner?: string | null /** Format: markdown */ description?: string /** Format: url */ - icon?: string - posting_warning?: string + icon?: string | null + posting_warning?: string | null /** * Format: datetime * @example 2025-06-07T02:29:07.980084Z @@ -3775,8 +4132,8 @@ export interface components { updated?: string } CommunityBlockView: { - community: components['schemas']['Community'] - person: components['schemas']['Person'] + community?: components['schemas']['Community'] + person?: components['schemas']['Person'] } CommunityFollowerView: { community: components['schemas']['Community'] @@ -3813,8 +4170,9 @@ export interface components { | 'Subscribed' | 'Popular' | 'Moderating' + | 'ModeratorView' /** @enum {string} */ - default_sort_type: + default_sort_type?: | 'Active' | 'Hot' | 'New' @@ -3830,6 +4188,7 @@ export interface components { | 'TopYear' | 'TopAll' | 'Scaled' + | 'Old' show_bot_accounts: boolean show_nsfl: boolean show_nsfw: boolean @@ -3948,7 +4307,7 @@ export interface components { * Format: url * @description Legacy tags that existed prior to 1.2 and some tags for remote communities might not have a defined ap_id */ - ap_id: string + ap_id: string | null } CommunityView: { activity_alert: boolean @@ -3975,6 +4334,16 @@ export interface components { published: string score: number upvotes: number + cross_posts: number + } + WidthHeight: { + width?: number + height?: number + } + MiniCrossPosts: { + post_id?: number + reply_count?: number + community_name?: string } Post: { /** Format: url */ @@ -4009,6 +4378,8 @@ export interface components { updated?: string /** Format: url */ url?: string + image_details?: components['schemas']['WidthHeight'] + cross_posts?: components['schemas']['MiniCrossPosts'][] } PostView: { banned_from_community: boolean @@ -4130,7 +4501,7 @@ export interface components { } ListCommunitiesResponse: { communities: components['schemas']['CommunityView'][] - next_page?: string + next_page?: string | null } FollowCommunityRequest: { community_id: number @@ -4152,12 +4523,12 @@ export interface components { name: string title: string /** Format: url */ - banner_url?: string + banner_url?: string | null /** Format: markdown */ description?: string discussion_languages?: number[] /** Format: url */ - icon_url?: string + icon_url?: string | null local_only?: boolean nsfw?: boolean restricted_to_mods?: boolean @@ -4167,12 +4538,12 @@ export interface components { community_id: number title?: string /** Format: url */ - banner_url?: string + banner_url?: string | null /** Format: markdown */ description?: string discussion_languages?: number[] /** Format: url */ - icon_url?: string + icon_url?: string | null local_only?: boolean nsfw?: boolean restricted_to_mods?: boolean @@ -4203,17 +4574,17 @@ export interface components { * Format: datetime * @example 2025-06-07T02:29:07.980084Z, null=permanent ban */ - expired_at?: string + expired_at?: string | null /** * Format: datetime * @example 2025-06-07T02:29:07.980084Z, null=permanent ban */ - expires_at?: string + expires_at?: string | null reason?: string } CommunityModerationBansListResponse: { items?: components['schemas']['CommunityModerationBanItem'][] - next_page?: string + next_page?: string | null } CommunityModerationUnbanRequest: { community_id: number @@ -4271,7 +4642,7 @@ export interface components { * Format: url * @description Legacy tags that existed prior to 1.2 and some tags for remote communities might not have a defined ap_id */ - ap_id: string + ap_id: string | null } CommunityFlairEditRequest: { flair_id: number @@ -4307,7 +4678,7 @@ export interface components { * Format: url * @description Legacy tags that existed prior to 1.2 and some tags for remote communities might not have a defined ap_id */ - ap_id: string + ap_id: string | null } CommunityFlairDeleteRequest: { flair_id: number @@ -4351,14 +4722,14 @@ export interface components { /** @description user_id of the feed creator/owner */ user_id: number /** Format: url */ - banner?: string + banner?: string | null /** Format: markdown */ - description?: string + description?: string | null /** Format: html */ - description_html?: string + description_html?: string | null /** Format: url */ - icon?: string - parent_feed_id?: number + icon?: string | null + parent_feed_id?: number | null } FeedListResponse: { feeds: components['schemas']['FeedView'][] @@ -4371,7 +4742,7 @@ export interface components { name: string show_posts_from_children: boolean title: string - parent_topic_id?: number + parent_topic_id?: number | null } TopicListResponse: { topics: components['schemas']['TopicView'][] @@ -4429,11 +4800,11 @@ export interface components { subscribed: 'Subscribed' | 'NotSubscribed' | 'Pending' } UserRepliesResponse: { - next_page: number + next_page?: string | null replies: components['schemas']['CommentReplyView'][] } UserMentionsResponse: { - next_page: number + next_page?: string | null replies: components['schemas']['CommentReplyView'][] } UserBlockRequest: { @@ -4461,14 +4832,14 @@ export interface components { * Format: url * @description Pass a null value to remove the image */ - avatar?: string + avatar?: string | null /** Format: markdown */ bio?: string /** * Format: url * @description Pass a null value to remove the image */ - cover?: string + cover?: string | null /** @enum {string} */ default_comment_sort_type?: 'Hot' | 'Top' | 'New' | 'Old' /** @enum {string} */ @@ -4518,7 +4889,7 @@ export interface components { /** @enum {string} */ status: 'All' | 'Unread' | 'Read' username: string - next_page: number + next_page?: string | null } UserNotificationStateRequest: { notif_id: number @@ -4535,14 +4906,14 @@ export interface components { UserSetFlairRequest: { community_id: number /** @description Either omit or set to null to remove existing flair */ - flair_text?: string + flair_text?: string | null } UserSetFlairResponse: { person_view: components['schemas']['PersonView'] } ListCommentsResponse: { comments: components['schemas']['CommentView'][] - next_page?: string + next_page?: string | null } LikeCommentRequest: { comment_id: number @@ -4578,7 +4949,11 @@ export interface components { body: string comment_id: number language_id?: number - distinguished?: boolean + /** + * @description Visibly mark reply as from a moderator in the web UI + * @default false + */ + distinguished: boolean } DeleteCommentRequest: { comment_id: number @@ -4598,7 +4973,7 @@ export interface components { id: number creator_id: number comment_id: number - original_comment_text: string + original_comment_text?: string reason?: string resolved: boolean /** @@ -4657,12 +5032,12 @@ export interface components { creator: components['schemas']['Person'] } ListCommentLikesResponse: { - comment_likes?: components['schemas']['CommentLikeView'][] - next_page?: string + comment_likes: components['schemas']['CommentLikeView'][] + next_page?: string | null } ListPostsResponse: { posts: components['schemas']['PostView'][] - next_page?: string + next_page?: string | null } GetPostResponse: { post_view: components['schemas']['PostView'] @@ -4690,12 +5065,13 @@ export interface components { } GetPostRepliesResponse: { comments?: components['schemas']['PostReplyView'][] - next_page?: string + next_page?: string | null } LikePostRequest: { post_id: number score: number private?: boolean + auth?: string } SavePostRequest: { post_id: number @@ -4739,7 +5115,11 @@ export interface components { original_post_body: string reason: string resolved: boolean - published: string + /** + * Format: datetime + * @example 2025-06-07T02:29:07.980084Z + */ + published?: string } PostReportView: { post_report: components['schemas']['PostReport'] @@ -4788,13 +5168,13 @@ export interface components { creator: components['schemas']['Person'] } ListPostLikesResponse: { - post_likes?: components['schemas']['PostLikeView'][] - next_page?: string + post_likes: components['schemas']['PostLikeView'][] + next_page?: string | null } PostSetFlairRequest: { post_id: number /** @description A list of all the flair id to assign to the post. Either pass an empty list or null to remove flair */ - flair_id_list?: number[] + flair_id_list?: number[] | null } PostSetFlairResponse: { banned_from_community: boolean @@ -4826,6 +5206,56 @@ export interface components { saved_only?: boolean q?: string } + PrivateMessage: { + id: number + creator_id: number + recipient_id: number + content: string + deleted: boolean + read: boolean + /** + * Format: datetime + * @example 2025-06-07T02:29:07.980084Z + */ + published: string + /** Format: url */ + ap_id: string + local: boolean + } + PrivateMessageView: { + private_message: components['schemas']['PrivateMessage'] + creator: components['schemas']['Person'] + recipient: components['schemas']['Person'] + } + ListPrivateMessagesResponse: { + private_messages: components['schemas']['PrivateMessageView'][] + } + GetPrivateMessageConversationResponse: { + private_messages: components['schemas']['PrivateMessageView'][] + } + CreatePrivateMessageRequest: { + content: string + recipient_id: number + } + PrivateMessageResponse: { + private_message_view: components['schemas']['PrivateMessageView'] + } + EditPrivateMessageRequest: { + private_message_id: number + content: string + } + MarkPrivateMessageAsReadRequest: { + private_message_id: number + read: boolean + } + DeletePrivateMessageRequest: { + private_message_id: number + deleted: boolean + } + ReportPrivateMessageRequest: { + private_message_id: number + reason: string + } } responses: { /** @description Unprocessable Content */ diff --git a/src/lib/client/types/schemas/GetPostsResponse.ts b/src/lib/client/types/schemas/GetPostsResponse.ts index d055fb80..3348090b 100644 --- a/src/lib/client/types/schemas/GetPostsResponse.ts +++ b/src/lib/client/types/schemas/GetPostsResponse.ts @@ -2,5 +2,5 @@ import type { PaginationCursor } from './schemas' import type { PostView } from './schemas' export interface GetPostsResponse { posts: Array - next_page?: PaginationCursor + next_page: PaginationCursor } diff --git a/src/lib/lemmy/feeds/feed.svelte.ts b/src/lib/lemmy/feeds/feed.svelte.ts index 400ac527..4a2e642c 100644 --- a/src/lib/lemmy/feeds/feed.svelte.ts +++ b/src/lib/lemmy/feeds/feed.svelte.ts @@ -56,7 +56,7 @@ export interface FeedTypes { { posts: PostView[] next_page?: string - params: GetPosts + params: GetPostss & { page_cursor: string } client: { itemHeights?: (number | null)[] lastSeen?: number @@ -69,7 +69,7 @@ export interface FeedTypes { posts: PostView[] community: GetCommunityResponse next_page?: string - params: GetPosts + params: GetPosts & { page_cursor: string } client: { itemHeights?: (number | null)[]; lastSeen?: number } }, ] @@ -110,7 +110,7 @@ export interface FeedTypes { { posts: PostView[] next_page?: string - params: GetPosts + params: GetPosts & { page_cursor: string } feed: Promise client: { itemHeights?: (number | null)[] @@ -123,7 +123,7 @@ export interface FeedTypes { { posts: PostView[] next_page?: string - params: GetPosts + params: GetPosts & { page_cursor: string } topic: Promise client: { itemHeights?: (number | null)[] diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 29bb728f..f5650f97 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -14,11 +14,14 @@ export async function load({ url, fetch, route }) { const listingType: ListingType = (url.searchParams.get('type') as ListingType) || settings.defaultSort.feed - const feedData = feed(route.id, async (params) => ({ - ...(await client({ func: fetch }).getPosts(params)), - params: params, - client: {}, - })).load({ + const feedData = feed(route.id, async (params) => { + const posts = await client({ func: fetch }).getPosts(params) + return { + ...posts, + params: { ...params, page_cursor: posts.next_page }, + client: {}, + } + }).load({ page_cursor: cursor, sort: sort, type_: listingType, diff --git a/src/routes/c/[name]/+page.svelte b/src/routes/c/[name]/+page.svelte index 4856b2a8..229beb33 100644 --- a/src/routes/c/[name]/+page.svelte +++ b/src/routes/c/[name]/+page.svelte @@ -51,13 +51,13 @@ {#snippet extended()} i.feeds.find((j) => j.id.toString() == p.feed_id!), ) + const postPromise = piefed.getPosts(p) + return { - ...(await piefed.getPosts(p)), + posts: (await postPromise).posts, + next_page: (await postPromise).next_page, feed: piefedFeedData, - params: p, + params: { ...p, page_cursor: (await postPromise).next_page }, client: {}, } }).load({ diff --git a/src/routes/topic/[id]/+page.ts b/src/routes/topic/[id]/+page.ts index cf9b9203..e77ff772 100644 --- a/src/routes/topic/[id]/+page.ts +++ b/src/routes/topic/[id]/+page.ts @@ -19,10 +19,12 @@ export async function load({ url, fetch, route, params }) { include_communities: true, }).then((i) => i.topics.find((j) => j.id.toString() == p.topic_id!)) + const posts = await piefed.getPosts(p) + return { - ...(await piefed.getPosts(p)), + ...posts, topic: piefedTopicData, - params: p, + params: { ...p, page_cursor: posts.next_page }, client: {}, } }).load({