feat(ProcessPostUseCase, HomeScreen, PostDetailScreen, PostService): implement share count synchronization after post sharing
Some checks failed
Frontend CI / build-and-push-web (push) Successful in 7m11s
Frontend CI / ota-android (push) Successful in 12m55s
Frontend CI / build-android-apk (push) Has been cancelled

- Added applyShareCountUpdate method in ProcessPostUseCase to synchronize share counts across post lists and details.
- Updated sharePost method in PostService to return the latest shares_count from the server.
- Modified share handling in HomeScreen and PostDetailScreen to utilize the new share count synchronization logic after a successful share operation.
- Enhanced error handling for share operations to improve user feedback.
This commit is contained in:
lafay
2026-03-24 05:21:46 +08:00
parent 48339384d2
commit f9f4e73747
4 changed files with 57 additions and 7 deletions

View File

@@ -333,6 +333,35 @@ class ProcessPostUseCase {
});
}
/**
* 分享计数上报成功后,同步各列表与详情中的分享数
*/
applyShareCountUpdate(postId: string, sharesCount: number): void {
this.postsState.forEach((state, key) => {
const index = state.posts.findIndex((p) => p.id === postId);
if (index !== -1) {
const newPosts = [...state.posts];
const cur = newPosts[index];
newPosts[index] = {
...cur,
sharesCount,
shares_count: sharesCount,
};
this.updatePostsState(key, { posts: newPosts });
}
});
const detail = this.getPostDetailState(postId);
if (detail.post) {
this.updatePostDetailState(postId, {
post: {
...detail.post,
sharesCount,
shares_count: sharesCount,
},
});
}
}
// ==================== 帖子列表操作 ====================
/**