From 4d127a038bf768eded68aae3cfa5c1b12241bdac Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Fri, 27 Mar 2026 00:55:15 +0100 Subject: chore: normalize line endings --- .../storage/migrations/transformers/v5-to-v6.ts | 176 ++++++++++----------- 1 file changed, 88 insertions(+), 88 deletions(-) (limited to 'apps/web/src/services/storage/migrations/transformers/v5-to-v6.ts') diff --git a/apps/web/src/services/storage/migrations/transformers/v5-to-v6.ts b/apps/web/src/services/storage/migrations/transformers/v5-to-v6.ts index ca855149..f3890f24 100644 --- a/apps/web/src/services/storage/migrations/transformers/v5-to-v6.ts +++ b/apps/web/src/services/storage/migrations/transformers/v5-to-v6.ts @@ -1,88 +1,88 @@ -import type { MigrationResult, ProjectRecord } from "./types"; -import { getProjectId, isRecord } from "./utils"; - -export function transformProjectV5ToV6({ - project, -}: { - project: ProjectRecord; -}): MigrationResult { - const projectId = getProjectId({ project }); - if (!projectId) { - return { project, skipped: true, reason: "no project id" }; - } - - if (isV6Project({ project })) { - return { project, skipped: true, reason: "already v6" }; - } - - const migratedProject = migrateProjectBookmarks({ project }); - - return { - project: { - ...migratedProject, - version: 6, - }, - skipped: false, - }; -} - -function migrateProjectBookmarks({ - project, -}: { - project: ProjectRecord; -}): ProjectRecord { - const scenesValue = project.scenes; - if (!Array.isArray(scenesValue)) { - return project; - } - - let hasSceneChanges = false; - const migratedScenes = scenesValue.map((scene) => { - const migratedScene = migrateSceneBookmarks({ scene }); - if (migratedScene !== scene) { - hasSceneChanges = true; - } - return migratedScene; - }); - - if (!hasSceneChanges) { - return project; - } - - return { - ...project, - scenes: migratedScenes, - }; -} - -function migrateSceneBookmarks({ scene }: { scene: unknown }): unknown { - if (!isRecord(scene)) { - return scene; - } - - const bookmarksValue = scene.bookmarks; - if (!Array.isArray(bookmarksValue)) { - return scene; - } - - const needsMigration = bookmarksValue.some( - (bookmark) => typeof bookmark === "number", - ); - if (!needsMigration) { - return scene; - } - - const migratedBookmarks = bookmarksValue.map((bookmark) => - typeof bookmark === "number" ? { time: bookmark } : bookmark, - ); - - return { - ...scene, - bookmarks: migratedBookmarks, - }; -} - -function isV6Project({ project }: { project: ProjectRecord }): boolean { - const versionValue = project.version; - return typeof versionValue === "number" && versionValue >= 6; -} +import type { MigrationResult, ProjectRecord } from "./types"; +import { getProjectId, isRecord } from "./utils"; + +export function transformProjectV5ToV6({ + project, +}: { + project: ProjectRecord; +}): MigrationResult { + const projectId = getProjectId({ project }); + if (!projectId) { + return { project, skipped: true, reason: "no project id" }; + } + + if (isV6Project({ project })) { + return { project, skipped: true, reason: "already v6" }; + } + + const migratedProject = migrateProjectBookmarks({ project }); + + return { + project: { + ...migratedProject, + version: 6, + }, + skipped: false, + }; +} + +function migrateProjectBookmarks({ + project, +}: { + project: ProjectRecord; +}): ProjectRecord { + const scenesValue = project.scenes; + if (!Array.isArray(scenesValue)) { + return project; + } + + let hasSceneChanges = false; + const migratedScenes = scenesValue.map((scene) => { + const migratedScene = migrateSceneBookmarks({ scene }); + if (migratedScene !== scene) { + hasSceneChanges = true; + } + return migratedScene; + }); + + if (!hasSceneChanges) { + return project; + } + + return { + ...project, + scenes: migratedScenes, + }; +} + +function migrateSceneBookmarks({ scene }: { scene: unknown }): unknown { + if (!isRecord(scene)) { + return scene; + } + + const bookmarksValue = scene.bookmarks; + if (!Array.isArray(bookmarksValue)) { + return scene; + } + + const needsMigration = bookmarksValue.some( + (bookmark) => typeof bookmark === "number", + ); + if (!needsMigration) { + return scene; + } + + const migratedBookmarks = bookmarksValue.map((bookmark) => + typeof bookmark === "number" ? { time: bookmark } : bookmark, + ); + + return { + ...scene, + bookmarks: migratedBookmarks, + }; +} + +function isV6Project({ project }: { project: ProjectRecord }): boolean { + const versionValue = project.version; + return typeof versionValue === "number" && versionValue >= 6; +} -- cgit v1.3.1