refactor: standardize pagination response structure and enhance cursor handling
- Update various services and hooks to replace 'items' with 'list' for consistency in pagination responses. - Modify PostRepository, commentService, groupService, messageService, and postService to align with the new response structure. - Enhance cursor pagination logic in hooks and components to ensure proper handling of pagination states. - Refactor HomeScreen, PostDetailScreen, SearchScreen, and other components to utilize the updated pagination structure.
This commit is contained in:
@@ -205,7 +205,7 @@ export interface CursorPaginationConfig {
|
||||
*/
|
||||
export interface CursorPaginationState<T> {
|
||||
/** 数据项列表 */
|
||||
items: T[];
|
||||
list: T[];
|
||||
/** 下一页游标 */
|
||||
nextCursor: string | null;
|
||||
/** 上一页游标 */
|
||||
@@ -235,7 +235,7 @@ export interface CursorPaginationActions<T> {
|
||||
/** 重置状态 */
|
||||
reset: () => void;
|
||||
/** 设置数据(用于外部数据注入) */
|
||||
setItems: (items: T[], nextCursor: string | null, prevCursor: string | null, hasMore: boolean) => void;
|
||||
setList: (list: T[], nextCursor: string | null, prevCursor: string | null, hasMore: boolean) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,7 +253,7 @@ export type CursorFetchFunction<T, P = void> = (params: {
|
||||
/** 额外参数 */
|
||||
extraParams?: P;
|
||||
}) => Promise<{
|
||||
items: T[];
|
||||
list: T[];
|
||||
next_cursor: string | null;
|
||||
prev_cursor: string | null;
|
||||
has_more: boolean;
|
||||
|
||||
Reference in New Issue
Block a user