getReadMembers method

List<Member> getReadMembers(
  1. BaseMessage message,
  2. {bool includeAllMembers = false}
)

Gets the member list who have read the given message.

If includeAllMembers is set false, this list excludes the current logged-in User and the sender of the message. Returns the list of members who have read the message.

Implementation

List<Member> getReadMembers(BaseMessage message,
    {bool includeAllMembers = false}) {
  sbLog.i(StackTrace.current,
      'messageId: ${message.messageId}, includeAllMembers: $includeAllMembers');

  if (message is AdminMessage) return [];
  if (isSuper) return [];

  return members.where((m) {
    if (!includeAllMembers && m.isCurrentUser) return false;
    if (message.sender?.userId == m.userId) return false;
    final readStatus = chat.channelCache.find<ReadStatus>(
      channelKey: channelUrl,
      key: m.userId,
    );
    if (readStatus == null || readStatus.timestamp == 0) return false;
    return readStatus.timestamp >= message.createdAt;
  }).toList();
}