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

@@ -250,14 +250,24 @@ class PostService {
}
}
// 分享帖子
async sharePost(postId: string): Promise<boolean> {
/** 上报分享成功;返回服务端最新 shares_count 供界面同步 */
async sharePost(
postId: string,
body?: { channel?: string }
): Promise<{ ok: boolean; shares_count?: number }> {
try {
const response = await api.post(`/posts/${postId}/share`);
return response.code === 0;
const response = await api.post<{ success: boolean; shares_count: number }>(
`/posts/${postId}/share`,
body && body.channel ? { channel: body.channel } : undefined
);
if (response.code !== 0) {
return { ok: false };
}
const n = response.data?.shares_count;
return { ok: true, shares_count: typeof n === 'number' ? n : undefined };
} catch (error) {
console.error('分享帖子失败:', error);
return false;
return { ok: false };
}
}