diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-27 00:55:15 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-29 15:56:48 +0200 |
| commit | 4d127a038bf768eded68aae3cfa5c1b12241bdac (patch) | |
| tree | 16bbb801caf6770546cff4fdb37b6408ec9ead98 /apps/web/src/services/storage/migrations/transformers/v18-to-v19.ts | |
| parent | 82817cb50cb0487350573d6129130aec705f924b (diff) | |
| download | opencut-4d127a038bf768eded68aae3cfa5c1b12241bdac.tar.gz | |
chore: normalize line endings
Diffstat (limited to 'apps/web/src/services/storage/migrations/transformers/v18-to-v19.ts')
| -rw-r--r-- | apps/web/src/services/storage/migrations/transformers/v18-to-v19.ts | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/apps/web/src/services/storage/migrations/transformers/v18-to-v19.ts b/apps/web/src/services/storage/migrations/transformers/v18-to-v19.ts index 1946b829..3afa5203 100644 --- a/apps/web/src/services/storage/migrations/transformers/v18-to-v19.ts +++ b/apps/web/src/services/storage/migrations/transformers/v18-to-v19.ts @@ -1,46 +1,46 @@ -import type { MigrationResult, ProjectRecord } from "./types"; -import { getProjectId, isRecord } from "./utils"; - -export function transformProjectV18ToV19({ - project, -}: { - project: ProjectRecord; -}): MigrationResult<ProjectRecord> { - if (!getProjectId({ project })) { - return { project, skipped: true, reason: "no project id" }; - } - - if (typeof project.version === "number" && project.version >= 19) { - return { project, skipped: true, reason: "already v19" }; - } - - return { - project: { - ...migrateCanvasSizeSettings({ project }), - version: 19, - }, - skipped: false, - }; -} - -function migrateCanvasSizeSettings({ - project, -}: { - project: ProjectRecord; -}): ProjectRecord { - const settingsValue = project.settings; - if (!isRecord(settingsValue)) { - return project; - } - - const migratedSettings: Record<string, unknown> = { - ...settingsValue, - canvasSizeMode: "preset", - lastCustomCanvasSize: null, - }; - - return { - ...project, - settings: migratedSettings, - }; -} +import type { MigrationResult, ProjectRecord } from "./types";
+import { getProjectId, isRecord } from "./utils";
+
+export function transformProjectV18ToV19({
+ project,
+}: {
+ project: ProjectRecord;
+}): MigrationResult<ProjectRecord> {
+ if (!getProjectId({ project })) {
+ return { project, skipped: true, reason: "no project id" };
+ }
+
+ if (typeof project.version === "number" && project.version >= 19) {
+ return { project, skipped: true, reason: "already v19" };
+ }
+
+ return {
+ project: {
+ ...migrateCanvasSizeSettings({ project }),
+ version: 19,
+ },
+ skipped: false,
+ };
+}
+
+function migrateCanvasSizeSettings({
+ project,
+}: {
+ project: ProjectRecord;
+}): ProjectRecord {
+ const settingsValue = project.settings;
+ if (!isRecord(settingsValue)) {
+ return project;
+ }
+
+ const migratedSettings: Record<string, unknown> = {
+ ...settingsValue,
+ canvasSizeMode: "preset",
+ lastCustomCanvasSize: null,
+ };
+
+ return {
+ ...project,
+ settings: migratedSettings,
+ };
+}
|
