bring back show folder

This commit is contained in:
Siddharth
2026-03-17 19:05:59 -07:00
parent 0f123283b3
commit 4b8c95f04f
2 changed files with 46 additions and 22 deletions
+4 -20
View File
@@ -1,6 +1,5 @@
import { Download, Loader2, X } from "lucide-react";
import { useEffect, useState } from "react";
import { toast } from "sonner"; // Add this import
import { Button } from "@/components/ui/button";
import type { ExportProgress } from "@/lib/exporter";
@@ -13,6 +12,7 @@ interface ExportDialogProps {
onCancel?: () => void;
exportFormat?: "mp4" | "gif";
exportedFilePath?: string;
onShowInFolder?: () => void;
}
export function ExportDialog({
@@ -23,7 +23,8 @@ export function ExportDialog({
error,
onCancel,
exportFormat = "mp4",
exportedFilePath, // Add this line
exportedFilePath,
onShowInFolder,
}: ExportDialogProps) {
const [showSuccess, setShowSuccess] = useState(false);
@@ -85,23 +86,6 @@ export function ExportDialog({
return `Exporting ${formatLabel}`;
};
const handleClickShowInFolder = async () => {
if (exportedFilePath) {
try {
const result = await window.electronAPI.revealInFolder(exportedFilePath);
if (!result.success) {
const errorMessage = result.error || result.message || "Failed to reveal item in folder.";
console.error("Failed to reveal in folder:", errorMessage);
toast.error(errorMessage);
}
} catch (err) {
const errorMessage = String(err);
console.error("Error calling revealInFolder IPC:", errorMessage);
toast.error(`Error revealing in folder: ${errorMessage}`);
}
}
};
return (
<>
<div
@@ -124,7 +108,7 @@ export function ExportDialog({
{exportedFilePath && (
<Button
variant="secondary"
onClick={handleClickShowInFolder}
onClick={onShowInFolder}
className="mt-2 w-fit px-3 py-1 text-sm rounded-md bg-white/10 hover:bg-white/20 text-slate-200"
>
Show in Folder
+42 -2
View File
@@ -103,6 +103,7 @@ export default function VideoEditor() {
const [gifFrameRate, setGifFrameRate] = useState<GifFrameRate>(15);
const [gifLoop, setGifLoop] = useState(true);
const [gifSizePreset, setGifSizePreset] = useState<GifSizePreset>("medium");
const [exportedFilePath, setExportedFilePath] = useState<string | null>(null);
const [lastSavedSnapshot, setLastSavedSnapshot] = useState<string | null>(null);
const videoPlaybackRef = useRef<VideoPlaybackRef>(null);
@@ -929,6 +930,37 @@ export default function VideoEditor() {
}
}, [selectedSpeedId, speedRegions]);
const handleShowExportedFile = useCallback(async (filePath: string) => {
try {
const result = await window.electronAPI.revealInFolder(filePath);
if (!result.success) {
const errorMessage = result.error || result.message || "Failed to reveal item in folder.";
console.error("Failed to reveal in folder:", errorMessage);
toast.error(errorMessage);
}
} catch (error) {
const errorMessage = String(error);
console.error("Error calling revealInFolder IPC:", errorMessage);
toast.error(`Error revealing in folder: ${errorMessage}`);
}
}, []);
const handleExportSaved = useCallback(
(formatLabel: "GIF" | "Video", filePath: string) => {
setExportedFilePath(filePath);
toast.success(`${formatLabel} exported successfully`, {
description: filePath,
action: {
label: "Show in Folder",
onClick: () => {
void handleShowExportedFile(filePath);
},
},
});
},
[handleShowExportedFile],
);
const handleExport = useCallback(
async (settings: ExportSettings) => {
if (!videoPath) {
@@ -945,6 +977,7 @@ export default function VideoEditor() {
setIsExporting(true);
setExportProgress(null);
setExportError(null);
setExportedFilePath(null);
try {
const wasPlaying = isPlaying;
@@ -1008,7 +1041,7 @@ export default function VideoEditor() {
if (saveResult.canceled) {
toast.info("Export canceled");
} else if (saveResult.success) {
toast.success(`GIF exported successfully to ${saveResult.path}`);
handleExportSaved("GIF", saveResult.path);
} else {
setExportError(saveResult.message || "Failed to save GIF");
toast.error(saveResult.message || "Failed to save GIF");
@@ -1135,7 +1168,7 @@ export default function VideoEditor() {
if (saveResult.canceled) {
toast.info("Export canceled");
} else if (saveResult.success) {
toast.success(`Video exported successfully to ${saveResult.path}`);
handleExportSaved("Video", saveResult.path);
} else {
setExportError(saveResult.message || "Failed to save video");
toast.error(saveResult.message || "Failed to save video");
@@ -1180,6 +1213,7 @@ export default function VideoEditor() {
isPlaying,
aspectRatio,
exportQuality,
handleExportSaved,
],
);
@@ -1222,6 +1256,7 @@ export default function VideoEditor() {
setShowExportDialog(true);
setExportError(null);
setExportedFilePath(null);
// Start export immediately
handleExport(settings);
@@ -1235,6 +1270,7 @@ export default function VideoEditor() {
setIsExporting(false);
setExportProgress(null);
setExportError(null);
setExportedFilePath(null);
}
}, []);
@@ -1473,6 +1509,10 @@ export default function VideoEditor() {
error={exportError}
onCancel={handleCancelExport}
exportFormat={exportFormat}
exportedFilePath={exportedFilePath || undefined}
onShowInFolder={
exportedFilePath ? () => void handleShowExportedFile(exportedFilePath) : undefined
}
/>
</div>
);