async commit()

in src/lib/state/checkpoints.svelte.ts [54:73]


	async commit(projectId: ProjectEntity["id"]) {
		const project = projects.all.find(p => p.id == projectId);
		if (!project) return;

		const newCheckpoint = await checkpointsRepo.save(
			snapshot({
				conversations: conversations.for(project.id).map(c => c.data),
				timestamp: new Date(),
				projectId: project.id,
			})
		);

		// Hack because dates are formatted to string by save
		newCheckpoint.conversations.forEach((c, i) => {
			newCheckpoint.conversations[i] = { ...c, createdAt: new Date(c.createdAt) };
		});

		const prev: Checkpoint[] = this.#checkpoints[projectId] ?? [];
		this.#checkpoints[projectId] = [...prev, newCheckpoint];
	}