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

@@ -514,7 +514,15 @@ export const PostDetailScreen: React.FC = () => {
const handleShare = useCallback(async () => {
if (!post?.id) return;
try {
await postService.sharePost(post.id);
const res = await postService.sharePost(post.id, { channel: 'copy_link' });
if (res.ok && res.shares_count != null) {
setPost((prev) =>
prev
? { ...prev, shares_count: res.shares_count!, sharesCount: res.shares_count! }
: null
);
processPostUseCase.applyShareCountUpdate(post.id, res.shares_count);
}
} catch (error) {
console.error('上报分享次数失败:', error);
}