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:
@@ -164,7 +164,7 @@ export const MessageListScreen: React.FC = () => {
|
||||
|
||||
// 【游标分页】使用 useCursorPagination hook 获取会话列表
|
||||
const {
|
||||
items: conversations,
|
||||
list: conversationList,
|
||||
isLoading,
|
||||
isRefreshing,
|
||||
hasMore,
|
||||
@@ -453,7 +453,7 @@ export const MessageListScreen: React.FC = () => {
|
||||
if (activeSearchTab === 'chat') {
|
||||
const results: SearchResultItem[] = [];
|
||||
|
||||
for (const conv of conversations) {
|
||||
for (const conv of conversationList) {
|
||||
await messageManager.fetchMessages(String(conv.id));
|
||||
const messages = messageManager.getMessages(String(conv.id));
|
||||
const matchedMessages = messages.filter(msg => {
|
||||
@@ -484,7 +484,7 @@ export const MessageListScreen: React.FC = () => {
|
||||
} finally {
|
||||
setIsSearching(false);
|
||||
}
|
||||
}, [conversations, activeSearchTab]);
|
||||
}, [conversationList, activeSearchTab]);
|
||||
|
||||
// 搜索文本变化时触发搜索
|
||||
useEffect(() => {
|
||||
@@ -533,7 +533,7 @@ export const MessageListScreen: React.FC = () => {
|
||||
// 合并列表数据
|
||||
const listData: ConversationResponse[] = [
|
||||
createSystemMessageItem(),
|
||||
...conversations,
|
||||
...conversationList,
|
||||
];
|
||||
|
||||
// 总未读数
|
||||
@@ -923,7 +923,7 @@ export const MessageListScreen: React.FC = () => {
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
{isLoading && conversations.length === 0 ? (
|
||||
{isLoading && conversationList.length === 0 ? (
|
||||
<View style={styles.loadingContainer}>
|
||||
<ActivityIndicator size="large" color={colors.primary.main} />
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user