applyThreadInfoUpdateEvent method

bool applyThreadInfoUpdateEvent(
  1. ThreadInfoUpdateEvent event
)

Applies ThreadInfoUpdateEvent to a message.

event from BaseChannelHandler.onThreadInfoUpdated. Return true if the event has been applied successfully.

Implementation

bool applyThreadInfoUpdateEvent(ThreadInfoUpdateEvent event) {
  sbLog.i(
      StackTrace.current, 'event.parentMessageId: ${event.targetMessageId}');

  if (messageId != event.targetMessageId) 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;
}