refactor(post): consolidate post sync to PostSyncService and remove ProcessPostUseCase
All checks were successful
Frontend CI / build-and-push-web (push) Successful in 3m28s
Frontend CI / ota-android (push) Successful in 10m25s
Frontend CI / build-android-apk (push) Successful in 55m22s

- Replace ProcessPostUseCase with new PostSyncService in src/services/post/
- Add postListStore for state management in src/stores/post/
- Remove deprecated ProcessPostUseCase and ProcessMessageUseCase files
- Delete architecture documentation files (ARCHITECTURE_REFACTOR_PLAN.md, architecture-comparison-report.md)
- Update all consumers (HomeScreen, PostDetailScreen, SearchScreen, useUserProfile, useDifferentialPosts)
- Simplify postService to only contain API layer methods
- Remove unused type exports from message stores

BREAKING CHANGE: ProcessPostUseCase and ProcessMessageUseCase have been removed.
Use postSyncService for post operations instead.
This commit is contained in:
lafay
2026-04-13 00:26:05 +08:00
parent 6610d2f173
commit 2adc9360a5
21 changed files with 679 additions and 2896 deletions

View File

@@ -37,7 +37,7 @@ import { Post, Comment, VoteResultDTO, VoteOptionDTO } from '../../types';
import { useUserStore } from '../../stores';
import { useCurrentUser } from '../../stores/authStore';
import { postService, commentService, uploadService, authService, showPrompt, voteService } from '../../services';
import { processPostUseCase } from '../../core/usecases/ProcessPostUseCase';
import { postSyncService } from '../../services/post/PostSyncService';
import { useCursorPagination } from '../../hooks/useCursorPagination';
import { CommentItem, VoteCard, ReportDialog } from '../../components/business';
import { Avatar, Button, Loading, EmptyState, Text, ImageGallery, ImageGrid, ImageGridItem, AdaptiveLayout, AppBackButton } from '../../components/common';
@@ -238,7 +238,7 @@ export const PostDetailScreen: React.FC = () => {
try {
// 使用 ProcessPostUseCase 获取帖子详情
const postData = await processPostUseCase.fetchPostById(postId);
const postData = await postSyncService.fetchPostById(postId);
if (postData) {
// 类型转换:将 core/entities/Post 转换为 PostDTO 以保持兼容性
setPost(postData as unknown as Post);
@@ -487,9 +487,9 @@ export const PostDetailScreen: React.FC = () => {
try {
if (originalPost.is_liked) {
await processPostUseCase.unlikePost(post.id);
await postSyncService.unlikePost(post.id);
} else {
await processPostUseCase.likePost(post.id);
await postSyncService.likePost(post.id);
}
} catch (error) {
handleError(error, { context: '点赞' });
@@ -505,9 +505,9 @@ export const PostDetailScreen: React.FC = () => {
try {
if (originalPost.is_favorited) {
await processPostUseCase.unfavoritePost(post.id);
await postSyncService.unfavoritePost(post.id);
} else {
await processPostUseCase.favoritePost(post.id);
await postSyncService.favoritePost(post.id);
}
} catch (error) {
handleError(error, { context: '收藏' });
@@ -526,7 +526,7 @@ export const PostDetailScreen: React.FC = () => {
? { ...prev, shares_count: res.shares_count!, sharesCount: res.shares_count! }
: null
);
processPostUseCase.applyShareCountUpdate(post.id, res.shares_count);
postSyncService.applyShareCountUpdate(post.id, res.shares_count);
}
} catch (error) {
console.error('上报分享次数失败:', error);
@@ -635,7 +635,7 @@ export const PostDetailScreen: React.FC = () => {
onPress: async () => {
setIsDeleting(true);
try {
await processPostUseCase.deletePost(post.id);
await postSyncService.deletePost(post.id);
Alert.alert('删除成功', '帖子已删除', [
{
text: '确定',