hiddenReasons static method

Set<HiddenEventReason> hiddenReasons(
  1. EventCacheStateRecord record,
  2. int now
)

Why visible reads hide the event behind record, empty when they do not.

superseded is reported only for an event that is neither deleted nor expired: those two exclude an event from winning its conflict domain, so they would otherwise always come with a redundant superseded.

Implementation

static Set<HiddenEventReason> hiddenReasons(
  EventCacheStateRecord record,
  int now,
) {
  final reasons = <HiddenEventReason>{};
  if (record.isExpiredAt(now)) {
    reasons.add(HiddenEventReason.expired);
  }
  if (record.isDeleted) {
    reasons.add(HiddenEventReason.deleted);
  }
  if (reasons.isEmpty &&
      !record.isCurrent &&
      EventKindClassification.isReplaceableKind(record.kind)) {
    reasons.add(HiddenEventReason.superseded);
  }
  return reasons;
}