toDocBody function

SyncDocBody toDocBody(
  1. Map<String, dynamic> exported,
  2. ComponentEntry e,
  3. ComponentMemory memory
)

Thân doc từ cấu hình đã gộp lớp phủ (exported = exportOf(id)) + bản ghi trong sổ. Kế hoạch: routes → routeIds (theo day). Popup: bỏ open — mở / đóng thẻ là trạng thái của từng người xem, không ép lên máy khác.

Implementation

SyncDocBody toDocBody(
  Map<String, dynamic> exported,
  ComponentEntry e,
  ComponentMemory memory,
) {
  final config = Map<String, dynamic>.from(exported);
  if (config['type'] == 'trip-plan') {
    config.remove('routes');
    config['routeIds'] = memory.routesOf(config['id'] as String);
  } else if (config['type'] == 'popup') {
    config.remove('open');
  }
  return (
    v: 1,
    config: config,
    origin: e.origin,
    visible: e.state.visible,
    meta: SyncDocMeta(
      stopOf: e.stopOf,
      alongOf: e.alongOf,
      anchorTo: e.anchorTo,
      planOf: e.planOf,
      tags: [...e.tags],
    ),
    adopted: e.adopted,
  );
}