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:
@@ -72,7 +72,7 @@ export const PostDetailScreen: React.FC = () => {
|
||||
|
||||
// 使用游标分页 Hook 管理评论列表
|
||||
const {
|
||||
items: paginatedComments,
|
||||
list: paginatedComments,
|
||||
isLoading: isCommentsLoading,
|
||||
isRefreshing: isCommentsRefreshing,
|
||||
hasMore: hasMoreComments,
|
||||
@@ -206,13 +206,13 @@ export const PostDetailScreen: React.FC = () => {
|
||||
|
||||
// 如果是从评论按钮跳转过来的,加载完成后滚动到评论区
|
||||
useEffect(() => {
|
||||
if (shouldScrollToComments && !loading && comments.length > 0) {
|
||||
if (shouldScrollToComments && !loading && (comments?.length ?? 0) > 0) {
|
||||
// 延迟确保列表已完成渲染和布局
|
||||
setTimeout(() => {
|
||||
flatListRef.current?.scrollToIndex({ index: 0, animated: true, viewPosition: 0 });
|
||||
}, 500);
|
||||
}
|
||||
}, [shouldScrollToComments, loading, comments.length]);
|
||||
}, [shouldScrollToComments, loading, comments?.length]);
|
||||
|
||||
// 动态设置导航头部
|
||||
useEffect(() => {
|
||||
@@ -1413,7 +1413,7 @@ export const PostDetailScreen: React.FC = () => {
|
||||
加载更多评论
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
) : comments.length > 0 ? (
|
||||
) : (comments?.length ?? 0) > 0 ? (
|
||||
<Text variant="caption" color={colors.text.hint} style={styles.noMoreComments}>
|
||||
没有更多评论了
|
||||
</Text>
|
||||
@@ -1546,7 +1546,7 @@ export const PostDetailScreen: React.FC = () => {
|
||||
加载更多评论
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
) : comments.length > 0 ? (
|
||||
) : (comments?.length ?? 0) > 0 ? (
|
||||
<Text variant="caption" color={colors.text.hint} style={styles.noMoreComments}>
|
||||
没有更多评论了
|
||||
</Text>
|
||||
|
||||
Reference in New Issue
Block a user