♻️ refactor!: massive refactor

This commit is contained in:
2026-05-31 03:04:30 +07:00
parent c1f12c7201
commit df3c944547
86 changed files with 3691 additions and 1129 deletions
@@ -1,8 +1,11 @@
import React from "react";
import { createProject } from "@pien-studio/editor-core";
import { upsertProject } from "@pien-studio/storage";
import { localProjectRepository } from "../lib/project-repository";
type Translator = (key: string, params?: Record<string, string | number>) => string;
type Translator = (
key: string,
params?: Record<string, string | number>,
) => string;
type UseEditorProjectLifecycleOptions = {
projectId: string;
@@ -12,7 +15,9 @@ type UseEditorProjectLifecycleOptions = {
t: Translator;
};
export function useEditorProjectLifecycle(options: UseEditorProjectLifecycleOptions) {
export function useEditorProjectLifecycle(
options: UseEditorProjectLifecycleOptions,
) {
const { projectId, hydrate, loadProjectById, setProject, t } = options;
const initializedProjectId = React.useRef<string | null>(null);
@@ -27,7 +32,7 @@ export function useEditorProjectLifecycle(options: UseEditorProjectLifecycleOpti
if (projectId === "new") {
const nextProject = createProject(t("home.untitledProject"));
setProject(nextProject);
void upsertProject(nextProject);
void localProjectRepository.upsertProject(nextProject);
return;
}
void loadProjectById(projectId);