getUnreadMembers method

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

Returns a list of Member who has not read given message. If includeAll is provided as true then current user will be included as well.

Implementation

List<Member> getUnreadMembers(BaseMessage message,
    {bool includeAll = false}) {
  if (message is AdminMessage) return [];
  if (isSuper) return [];
  // if (_sdk.state.currentUser == null) return []; //check connection

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