onUnfollow method

void onUnfollow({
  1. required FeedId sourceFid,
  2. required FeedId targetFid,
})

Handles updates to the feed state when an unfollow action occurs.

Implementation

void onUnfollow({required FeedId sourceFid, required FeedId targetFid}) {
  // Remove the follow relationship between sourceFid and targetFid
  final updatedFollowing = state.following.whereNot((it) {
    var filter = it.sourceFeed.id == sourceFid.id;
    return filter &= it.targetFeed.id == targetFid.id;
  }).toList();

  state = state.copyWith(following: updatedFollowing);
}