@@ -8,13 +8,16 @@ import { JikeUser } from './user'
88import { fetchPaginated } from './utils/paginate'
99import { AuthorizationError } from './errors/AuthorizationError'
1010import { JikePost } from './post'
11+ import type { PersonalUpdate } from '../types/api-responses'
1112import type { CreatePostOption , PostType } from '../types/options'
12- import type { Notification } from '../types/entity'
13+ import type { Notification , PostDetail } from '../types/entity'
1314import type { BeforeRetryState } from 'ky/distribution/types/hooks'
1415import type { PaginatedFetcher , PaginatedOption } from './utils/paginate'
1516import type { Api } from '../api'
1617import type { ApiConfig , ApiConfigResolved } from '../request'
1718
19+ type FollowingUpdatesMoreKey = PersonalUpdate . FollowingUpdatesResponseMoreKey
20+
1821export class JikeClient {
1922 #refreshToken: string
2023 #config: ApiConfigResolved
@@ -194,6 +197,37 @@ export class JikeClient {
194197 )
195198 }
196199
200+ /**
201+ * 查询关注动态
202+ */
203+ async queryFollowingUpdates (
204+ option : PaginatedOption <
205+ PostDetail ,
206+ 'createdAt' ,
207+ FollowingUpdatesMoreKey
208+ > = { }
209+ ) {
210+ const fetcher : PaginatedFetcher <
211+ PostDetail ,
212+ FollowingUpdatesMoreKey
213+ > = async ( lastKey ) => {
214+ const result = await this . #client. personalUpdate . followingUpdates ( {
215+ loadMoreKey : lastKey ,
216+ } )
217+ if ( ! isSuccess ( result ) ) throwRequestFailureError ( result , '查询关注动态' )
218+ const newKey = result . data . loadMoreKey
219+ return [ newKey , result . data . data ]
220+ }
221+ return fetchPaginated (
222+ fetcher ,
223+ ( item , data ) => ( {
224+ createdAt : new Date ( item . createdAt ) ,
225+ total : data . length + 1 ,
226+ } ) ,
227+ option
228+ )
229+ }
230+
197231 /**
198232 *
199233 * @param type 动态类型,原帖 或 转发
0 commit comments