canAddMessage method

bool canAddMessage(
  1. CollectionEventSource eventSource,
  2. BaseMessage addedMessage
)

Implementation

bool canAddMessage(
  CollectionEventSource eventSource,
  BaseMessage addedMessage,
) {
  if (eventSource == CollectionEventSource.messageLoadPrevious ||
      eventSource == CollectionEventSource.messageLoadNext) {
    return true;
  }

  if (messageList.isEmpty) {
    return false;
  }

  if (messageList.isNotEmpty && hasNext) {
    final a = messageList.last;
    final b = addedMessage;

    if (a.createdAt < b.createdAt) {
      return false;
    }
  }
  return true;
}