getReadStatus method

Map<String, Map<String, dynamic>> getReadStatus(
  1. bool includeAllMembers
)

Gets ReadStatus for all members in this GroupChannel.

If includeAllMembers is set false, this excludes the current User. Returns Map with User ID keys.

Implementation

Map<String, Map<String, dynamic>> getReadStatus(bool includeAllMembers) {
  sbLog.i(StackTrace.current, 'includeAllMembers: $includeAllMembers');
  if (isSuper) return {};

  return Map.fromIterable(
    members.where((member) {
      if (!includeAllMembers && member.isCurrentUser) return false;
      return true;
    }),
    key: (member) => member.userId,
    value: (member) {
      final readStatus = chat.channelCache.find<ReadStatus>(
        channelKey: channelUrl,
        key: member.userId,
      );
      return {'user': member, 'last_seen_at': readStatus?.timestamp};
    },
  );
}