@@ -3,15 +3,16 @@ import EventEmitter from 'eventemitter3'
33import { resolveApiConfig } from '../request'
44import { ApiClient } from '../api-client'
55import { objectPick } from '../utils'
6+ import { PostType } from '../types/options'
67import { isSuccess , throwRequestFailureError } from './utils/response'
78import { resolveAreaCode } from './utils/user'
89import { JikeUser } from './user'
910import { fetchPaginated } from './utils/paginate'
1011import { AuthorizationError } from './errors/AuthorizationError'
11- import { JikePost } from './post'
12+ import { JikePost , JikePostWithDetail } from './post'
13+ import type { CreatePostOption } from '../types/options'
1214import type { FollowingUpdatesMoreKey , JikeClientJSON } from './types'
13- import type { CreatePostOption , PostType } from '../types/options'
14- import type { FollowingUpdate , Notification } from '../types/entity'
15+ import type { FollowingUpdate , Notification , Post } from '../types/entity'
1516import type { BeforeRetryState } from 'ky/distribution/types/hooks'
1617import type { PaginatedFetcher , PaginatedOption } from './utils/paginate'
1718import type { Api } from '../api'
@@ -228,14 +229,22 @@ export class JikeClient extends EventEmitter<EventMap> {
228229 const newKey = result . data . loadMoreKey
229230 return [ newKey , result . data . data ]
230231 }
231- return fetchPaginated (
232+ const updates = await fetchPaginated (
232233 fetcher ,
233234 ( item , data ) => ( {
234235 createdAt : new Date ( item . createdAt ) ,
235236 total : data . length + 1 ,
236237 } ) ,
237238 option
238239 )
240+ return updates . map ( ( update ) => {
241+ // TODO repost
242+ if ( update . type === 'ORIGINAL_POST' ) {
243+ return this . getPost ( PostType . ORIGINAL , update . id , update )
244+ } else {
245+ return update
246+ }
247+ } )
239248 }
240249
241250 /**
@@ -253,14 +262,21 @@ export class JikeClient extends EventEmitter<EventMap> {
253262 if ( ! isSuccess ( result ) ) throwRequestFailureError ( result , '发送动态' )
254263 return {
255264 /** 动态 */
256- post : new JikePost ( this , type , result . data . data . id , result . data . data ) ,
265+ post : this . getPost ( type , result . data . data . id , result . data . data ) ,
257266 /** 提示文本 */
258267 toast : result . data . toast ,
259268 }
260269 }
261270
262- getPost ( type : PostType , id : string ) {
263- return new JikePost ( this , type , id )
271+ getPost ( type : PostType , id : string ) : JikePost
272+ getPost ( type : PostType , id : string , detail : Post ) : JikePostWithDetail
273+ getPost (
274+ type : PostType ,
275+ id : string ,
276+ detail ?: Post
277+ ) : JikePost | JikePostWithDetail {
278+ if ( ! detail ) return new JikePost ( this , type , id )
279+ else return new JikePostWithDetail ( this , type , id , detail )
264280 }
265281
266282 /**
0 commit comments