From 7f0338c9a7b24b76d86962bced652e1439d3ade3 Mon Sep 17 00:00:00 2001 From: soraefir Date: Thu, 15 May 2025 00:19:55 +0200 Subject: [PATCH] WIP --- src/client/api.ts | 2 +- src/client/types/format.ts | 1 + src/client/types/migration.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/api.ts b/src/client/api.ts index 1d44418..3e56c8b 100644 --- a/src/client/api.ts +++ b/src/client/api.ts @@ -41,7 +41,7 @@ export const load = (id: string) => return res; }); -export const save = (id: string, v: journey) =>{ +export const save = async (id: string, v: journey) =>{ v.version = v.version +1 return fetch("/api/" + id, { method: "post", body: JSON.stringify(v) }) .then((res) => { diff --git a/src/client/types/format.ts b/src/client/types/format.ts index 50fb843..ff636c5 100644 --- a/src/client/types/format.ts +++ b/src/client/types/format.ts @@ -55,6 +55,7 @@ const leg_template: leg = { } const journey_template: journey = { fmt_ver: 1, + version:0, title: "New Journey", main: [leg_template], } diff --git a/src/client/types/migration.ts b/src/client/types/migration.ts index e65c3f8..9df2d38 100644 --- a/src/client/types/migration.ts +++ b/src/client/types/migration.ts @@ -10,7 +10,7 @@ function migrate_A_to_0(e: journey): journey { v.travel = v.travel || []; v.day_title = typeof (v.day_title) == "string" ? [v.day_title] : []; }) - e.version = e.version | 0; + e.version = e.version || 0; console.log(e) return e; }