fix: plans - like and bookmark in consultant profile (#582)

- decouple PlanWidget from feed PlansCubit via owner-provided callbacks
- add like/favorite actions to profile PlansCubit: slug lookup, optimistic
  update, rollback of the affected plan, per-slug debounce, isClosed guards
- pass slug through like/favorite/comments events; guard out-of-range index
  in feed plans handlers and deep-link about_plan sync
- capture post like intent before await in profile blog post widget
- replace null force-unwraps in profile screen, guard indexOf == -1
- tests: profile plan like/bookmark, slug sync, bounds guards, #700 regression
This commit is contained in:
2026-11-20 16:30:13 +03:00
parent 1e8c1ab2eb
commit 0df474b2b5
22 changed files with 2139 additions and 137 deletions

View File

@@ -191,21 +191,24 @@ class _ProfileBlogPostWidgetState extends State<ProfileBlogPostWidget> {
? Colors.red.withValues(alpha: 0.8)
: null,
onTap: () async {
final nextLiked = !isLiked;
setState(() {
isLiked = !isLiked;
isLiked ? totalLikes++ : totalLikes--;
isLiked = nextLiked;
nextLiked ? totalLikes++ : totalLikes--;
});
isLiked
? await context.read<FeedCubit>().likePost(
post.id,
)
: await context.read<FeedCubit>().unlikedPost(
post.id,
);
widget.profileCubit.updateFeedBlogPostList(
post,
isLiked ? false : true,
nextLiked,
);
if (nextLiked) {
await context.read<FeedCubit>().likePost(
post.id,
);
} else {
await context.read<FeedCubit>().unlikedPost(
post.id,
);
}
},
),
const SizedBox(width: 8),