ChatEntry constructor

ChatEntry(
  1. RxChat _chat, [
  2. void sort()?
])

Returns a ChatEntry capturing the provided chat changes to invoke a sort on Chat.updatedAt or Chat.ongoingCall updates.

Implementation

ChatEntry(this._chat, [void Function()? sort]) {
  _updatedAt = _chat.chat.value.updatedAt;
  _hasCall = _chat.chat.value.ongoingCall != null;

  _worker = ever(_chat.chat, (Chat chat) {
    bool hasCall = chat.ongoingCall != null;
    if (chat.updatedAt != _updatedAt || hasCall != _hasCall) {
      sort?.call();
      _updatedAt = chat.updatedAt;
      _hasCall = hasCall;
    }
  });
}