snapshot method

JsonMap snapshot(
  1. String principalId
)

The API Snapshot of principalId (04 6.3 item 4, 04 7.3).

Implementation

JsonMap snapshot(String principalId) {
  final person = people[principalId]!;
  return {
    'head_seq': headSeq,
    'permission_version': permissionVersion,
    'sync_epoch': syncEpoch,
    'principal': person.ref,
    'is_owner': person.isOwner,
    'spaces': spaceViews(principalId),
    'channels': channelViews(principalId),
    'sidebar': sidebarOf(principalId),
    'unread_threads': unreadThreads(principalId),
    'active_runs': [
      for (final r in runs.values)
        if (_active(r) &&
            seesChannel(principalId, r['channel_id']! as String))
          runSummary(r),
    ],
    'agents': <Object?>[],
    'settings': [...?settings[principalId]?.values],
    'drafts': [
      for (final MapEntry(:key, :value) in drafts.entries)
        if (key.startsWith('$principalId|'))
          {
            'id': value['id'],
            'thread_id': ?value['thread_id'],
            'channel_id': value['channel_id'],
            'version': value['version'],
          },
    ],
    'features': <Object?>[],
  };
}