added save as
This commit is contained in:
@ -33,6 +33,7 @@ type Panel = 'ai' | 'settings' | 'export' | 'silence' | 'zones' | null;
|
||||
|
||||
export default function App() {
|
||||
const {
|
||||
projectFilePath,
|
||||
videoPath,
|
||||
exportedAudioPath,
|
||||
words,
|
||||
@ -48,6 +49,7 @@ export default function App() {
|
||||
isTranscribing,
|
||||
transcriptionStatus,
|
||||
loadVideo,
|
||||
setProjectFilePath,
|
||||
setBackendUrl,
|
||||
setTranscription,
|
||||
setTranscriptionModel,
|
||||
@ -179,6 +181,7 @@ export default function App() {
|
||||
if (!projectPath) return;
|
||||
const content = await window.electronAPI!.readFile(projectPath);
|
||||
const data = JSON.parse(content);
|
||||
setProjectFilePath(projectPath);
|
||||
loadProjectFromData(data);
|
||||
setProjectName(projectPath.split(/[/\\]/).pop()?.replace(/\.aive$/i, '') ?? null);
|
||||
} catch (err) {
|
||||
@ -188,14 +191,13 @@ export default function App() {
|
||||
});
|
||||
};
|
||||
|
||||
const handleSaveProject = async (): Promise<boolean> => {
|
||||
const writeProjectToPath = async (path: string): Promise<boolean> => {
|
||||
try {
|
||||
const savePath = await window.electronAPI!.saveProject();
|
||||
if (!savePath) return false;
|
||||
const data = useEditorStore.getState().saveProject();
|
||||
const path = savePath.endsWith('.aive') ? savePath : `${savePath}.aive`;
|
||||
await window.electronAPI!.writeFile(path, JSON.stringify(data, null, 2));
|
||||
setProjectName(path.split(/[/\\]/).pop()?.replace(/\.aive$/i, '') ?? null);
|
||||
const resolvedPath = path.endsWith('.aive') ? path : `${path}.aive`;
|
||||
await window.electronAPI!.writeFile(resolvedPath, JSON.stringify(data, null, 2));
|
||||
setProjectFilePath(resolvedPath);
|
||||
setProjectName(resolvedPath.split(/[/\\]/).pop()?.replace(/\.aive$/i, '') ?? null);
|
||||
if (projectSignature) {
|
||||
setLastSavedSignature(projectSignature);
|
||||
}
|
||||
@ -207,11 +209,26 @@ export default function App() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSaveProjectAs = async (): Promise<boolean> => {
|
||||
const savePath = await window.electronAPI!.saveProject();
|
||||
if (!savePath) return false;
|
||||
return writeProjectToPath(savePath);
|
||||
};
|
||||
|
||||
const handleSaveProject = async (): Promise<boolean> => {
|
||||
if (!projectFilePath) {
|
||||
return handleSaveProjectAs();
|
||||
}
|
||||
return writeProjectToPath(projectFilePath);
|
||||
};
|
||||
|
||||
const handleOpenFile = async () => {
|
||||
await runGuarded(async () => {
|
||||
const path = await window.electronAPI!.openFile();
|
||||
if (path) {
|
||||
setLastSavedSignature(null);
|
||||
setProjectFilePath(null);
|
||||
setProjectName(null);
|
||||
loadVideo(path);
|
||||
await transcribeVideo(path);
|
||||
}
|
||||
@ -223,6 +240,8 @@ export default function App() {
|
||||
useEditorStore.getState().reset();
|
||||
setLastSavedSignature(null);
|
||||
setActivePanel(null);
|
||||
setProjectFilePath(null);
|
||||
setProjectName(null);
|
||||
setCutMode(false);
|
||||
setMuteMode(false);
|
||||
setGainMode(false);
|
||||
@ -458,6 +477,12 @@ export default function App() {
|
||||
onClick={handleSaveProject}
|
||||
disabled={words.length === 0}
|
||||
/>
|
||||
<ToolbarButton
|
||||
icon={<Save className="w-4 h-4" />}
|
||||
label="Save As"
|
||||
onClick={handleSaveProjectAs}
|
||||
disabled={words.length === 0}
|
||||
/>
|
||||
<ToolbarButton
|
||||
icon={<FileInput className="w-4 h-4" />}
|
||||
label="Load"
|
||||
|
||||
Reference in New Issue
Block a user