Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function App() {
const [openMenuVisible, setOpenMenuVisible] = useState(false);
const [exportMenuVisible, setExportMenuVisible] = useState(false);
const canvasRef = useRef<HTMLCanvasElement>(null);
const [exportProgress, setExportProgress] = useState({ current: 0, total: 0 });

useBackgroundProcessor();
const { updateState, dismissUpdateError, triggerUpdate, restartApp } = useUpdater();
Expand Down Expand Up @@ -79,7 +80,8 @@ function App() {
showToast,
profile: settings.profile,
visibility: settings.visibility,
globalJpegQuality: settings.globalJpegQuality
globalJpegQuality: settings.globalJpegQuality,
onProgress: (current, total) => setExportProgress({ current, total })
});

useEffect(() => {
Expand Down Expand Up @@ -218,7 +220,12 @@ function App() {
}}>
<div className="top-bar-left">
<h1>ExifFrame</h1>
{updateState.stage !== 'idle' && (() => {
{exportProgress.total > 0 ? (
<button className="btn btn-update btn-update--progress" disabled title="Exporting images...">
<span className="update-progress-bar" style={{ width: `${(exportProgress.current / exportProgress.total) * 100}%` }} />
<span className="update-progress-text">Exporting... {exportProgress.current} / {exportProgress.total}</span>
</button>
) : updateState.stage !== 'idle' && (() => {
const { stage, version, downloadPct, errorMessage, releaseNotes } = updateState;
if (stage === 'checking') {
return (
Expand Down
17 changes: 16 additions & 1 deletion frontend/src/hooks/useExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export interface UseExportProps {
profile: string;
visibility: MetadataVisibility;
globalJpegQuality: string;

onProgress?: (current: number, total: number) => void;
}

const uploadCanvasBlob = async (
Expand Down Expand Up @@ -59,7 +61,7 @@ const uploadCanvasBlob = async (
export function useExport({
canvasRef, imageObj, currentImage, importedImages,
isSelectingRef, setIsSelecting, showToast,
profile, visibility, globalJpegQuality
profile, visibility, globalJpegQuality, onProgress
}: UseExportProps) {

const downloadImage = async () => {
Expand Down Expand Up @@ -117,8 +119,19 @@ export function useExport({
let successCount = 0;
let failCount = 0;

const safeOnProgress = (current: number, total: number) => {
if (onProgress) {
try {
onProgress(current, total);
} catch (e) {
console.error("onProgress failed:", e);
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
};

try {
showToast("Exporting images...");
safeOnProgress(0, importedImages.length);

for (let i = 0; i < importedImages.length; i++) {
const imgState = importedImages[i];
Expand Down Expand Up @@ -186,6 +199,7 @@ export function useExport({
if (imgToDraw && !imgState.imageObj) {
imgToDraw.src = "";
}
safeOnProgress(i + 1, importedImages.length);
}
}

Expand All @@ -201,6 +215,7 @@ export function useExport({
} finally {
setIsSelecting(false);
isSelectingRef.current = false;
safeOnProgress(0, 0); // Reset progress
}
};

Expand Down
Loading