applyThreadInfoUpdateEvent method Null safety

bool applyThreadInfoUpdateEvent(
  1. ThreadInfoUpdateEvent event
)

Applies ThreadInfoUpdateEvent event to this message.

This ThreadInfoUpdateEvent event can be acquired from ChannelEventHandler.onThreadInfoUpdated channel event and should be applied to corresponding message in order to display threaded messages properly.

Implementation

bool applyThreadInfoUpdateEvent(ThreadInfoUpdateEvent event) {
  if (messageId != event.rootMessageId) return false;
  if (threadInfo == null) {
    threadInfo = event.threadInfo;
    return true;
  }
  final updatedAt = threadInfo?.updatedAt ?? 0;
  final newUpdatedAt = event.threadInfo.updatedAt ?? 0;
  if (updatedAt <= newUpdatedAt) {
    threadInfo = event.threadInfo;
    return true;
  }
  return false;
}