StoryViews.deserialize constructor

StoryViews.deserialize(
  1. BinaryReader reader
)

Deserialize.

Implementation

factory StoryViews.deserialize(BinaryReader reader) {
  // Read [StoryViews] fields.
  final flags = reader.readInt32();
  final hasViewers = (flags & 2) != 0;
  final viewsCount = reader.readInt32();
  final hasForwardsCountField = (flags & 4) != 0;
  final forwardsCount = hasForwardsCountField ? reader.readInt32() : null;
  final hasReactionsField = (flags & 8) != 0;
  final reactions =
      hasReactionsField ? reader.readVectorObject<ReactionCountBase>() : null;
  final hasReactionsCountField = (flags & 16) != 0;
  final reactionsCount = hasReactionsCountField ? reader.readInt32() : null;
  final hasRecentViewersField = (flags & 1) != 0;
  final recentViewers =
      hasRecentViewersField ? reader.readVectorInt64() : null;

  // Construct [StoryViews] object.
  final returnValue = StoryViews(
    hasViewers: hasViewers,
    viewsCount: viewsCount,
    forwardsCount: forwardsCount,
    reactions: reactions,
    reactionsCount: reactionsCount,
    recentViewers: recentViewers,
  );

  // Now return the deserialized [StoryViews].
  return returnValue;
}