File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import type {
1313 TimelineItem ,
1414 CreateFeedRequest ,
1515 UpdateFeedRequest ,
16+ AdjacentFeedResponse ,
1617 UserProfile ,
1718 UpdateProfileRequest ,
1819 Tag ,
@@ -134,6 +135,7 @@ export type {
134135 TimelineItem ,
135136 CreateFeedRequest ,
136137 UpdateFeedRequest ,
138+ AdjacentFeedResponse ,
137139 UserProfile ,
138140 UpdateProfileRequest ,
139141 Tag ,
@@ -313,8 +315,8 @@ class FeedAPI {
313315 }
314316
315317 // GET /api/feed/adjacent/:id
316- async adjacent ( id : number | string ) : Promise < ApiResponse < { prev : Feed | null ; next : Feed | null } > > {
317- return this . http . get < { prev : Feed | null ; next : Feed | null } > ( `/api/feed/adjacent/${ id } ` ) ;
318+ async adjacent ( id : number | string ) : Promise < ApiResponse < AdjacentFeedResponse > > {
319+ return this . http . get < AdjacentFeedResponse > ( `/api/feed/adjacent/${ id } ` ) ;
318320 }
319321
320322 // POST /api/feed/top/:id
Original file line number Diff line number Diff line change 1+ import type { AdjacentFeed , AdjacentFeedResponse } from "@rin/api" ;
12import { useEffect , useState } from "react" ;
23import { client } from "../app/runtime" ;
34import { timeago } from "../utils/timeago.ts" ;
45import { Link } from "wouter" ;
56import { useTranslation } from "react-i18next" ;
67
7- export type AdjacentFeed = {
8- id : number ;
9- title : string | null ;
10- summary ?: string ;
11- hashtags ?: {
12- id : number ;
13- name : string ;
14- } [ ] ;
15- createdAt : Date | string ;
16- updatedAt : Date | string ;
17- } ;
18- export type AdjacentFeeds = {
19- nextFeed : AdjacentFeed | null ;
20- previousFeed : AdjacentFeed | null ;
21- } ;
22-
238export function AdjacentSection ( { id, setError} : { id : string , setError : ( error : string ) => void } ) {
24- const [ adjacentFeeds , setAdjacentFeeds ] = useState < AdjacentFeeds > ( ) ;
9+ const [ adjacentFeeds , setAdjacentFeeds ] = useState < AdjacentFeedResponse > ( ) ;
2510
2611 useEffect ( ( ) => {
2712 client . feed
2813 . adjacent ( id )
2914 . then ( ( { data, error} ) => {
3015 if ( error ) {
3116 setError ( error . value as string ) ;
32- } else if ( data ) {
33- setAdjacentFeeds ( {
34- nextFeed : data . next ,
35- previousFeed : data . prev
36- } ) ;
17+ } else if ( data && typeof data !== "string" ) {
18+ setAdjacentFeeds ( data ) ;
3719 }
3820 } ) ;
3921 } , [ id , setError ] ) ;
You can’t perform that action at this time.
0 commit comments