fetchPostDetails method

  1. @override
Future<TimelinePost> fetchPostDetails(
  1. TimelinePost post
)

Implementation

@override
Future<TimelinePost> fetchPostDetails(TimelinePost post) async {
  var reactions = post.reactions ?? [];
  var updatedReactions = <TimelinePostReaction>[];
  for (var reaction in reactions) {
    var user = await _userService.getUser(reaction.creatorId);
    if (user != null) {
      updatedReactions.add(reaction.copyWith(creator: user));
    }
  }
  var updatedPost = post.copyWith(
    reactions: updatedReactions,
    creator: await _userService.getUser(post.creatorId),
  );
  posts = posts.map((p) => (p.id == post.id) ? updatedPost : p).toList();
  notifyListeners();
  return updatedPost;
}