mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-08 17:51:20 +02:00
Remove merge error returning code
This commit is contained in:
parent
2419425dc9
commit
5e401d255e
@ -42,100 +42,9 @@ export default function HomePage() {
|
|||||||
const [pageEditorFunctions, setPageEditorFunctions] = useState<any>(null);
|
const [pageEditorFunctions, setPageEditorFunctions] = useState<any>(null);
|
||||||
const [previewFile, setPreviewFile] = useState<File | null>(null);
|
const [previewFile, setPreviewFile] = useState<File | null>(null);
|
||||||
|
|
||||||
// Tool registry
|
|
||||||
const toolRegistry: ToolRegistry = {
|
|
||||||
split: { ...baseToolRegistry.split, name: t("home.split.title", "Split PDF") },
|
|
||||||
compress: { ...baseToolRegistry.compress, name: t("home.compressPdfs.title", "Compress PDF") },
|
|
||||||
merge: { ...baseToolRegistry.merge, name: t("home.merge.title", "Merge PDFs") },
|
|
||||||
};
|
|
||||||
|
|
||||||
// Tool parameters with state management
|
|
||||||
const getToolParams = (toolKey: string | null) => {
|
|
||||||
if (!toolKey) return {};
|
|
||||||
|
|
||||||
// Get stored params for this tool, or use defaults
|
|
||||||
const storedParams = toolParams[toolKey] || {};
|
|
||||||
|
|
||||||
const defaultParams = (() => {
|
|
||||||
switch (toolKey) {
|
|
||||||
case 'split':
|
|
||||||
return {
|
|
||||||
mode: '',
|
|
||||||
pages: '',
|
|
||||||
hDiv: '2',
|
|
||||||
vDiv: '2',
|
|
||||||
merge: false,
|
|
||||||
splitType: 'size',
|
|
||||||
splitValue: '',
|
|
||||||
bookmarkLevel: '1',
|
|
||||||
includeMetadata: false,
|
|
||||||
allowDuplicates: false,
|
|
||||||
};
|
|
||||||
case 'compress':
|
|
||||||
return {
|
|
||||||
quality: 80,
|
|
||||||
imageCompression: true,
|
|
||||||
removeMetadata: false
|
|
||||||
};
|
|
||||||
case 'merge':
|
|
||||||
return {
|
|
||||||
sortOrder: 'name',
|
|
||||||
includeMetadata: true
|
|
||||||
};
|
|
||||||
default:
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
return { ...defaultParams, ...storedParams };
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateToolParams = useCallback((toolKey: string, newParams: any) => {
|
|
||||||
setToolParams(prev => ({
|
|
||||||
...prev,
|
|
||||||
[toolKey]: {
|
|
||||||
...prev[toolKey],
|
|
||||||
...newParams
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const activeFileData = activeFiles.map(file => ({
|
|
||||||
name: file.name,
|
|
||||||
size: file.size,
|
|
||||||
type: file.type,
|
|
||||||
lastModified: file.lastModified
|
|
||||||
}));
|
|
||||||
localStorage.setItem('activeFiles', JSON.stringify(activeFileData));
|
|
||||||
}, [activeFiles]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const loadStoredFiles = async () => {
|
|
||||||
try {
|
|
||||||
const files = await fileStorage.getAllFiles();
|
|
||||||
setStoredFiles(files);
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('Failed to load stored files:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
loadStoredFiles();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const restoreActiveFiles = async () => {
|
|
||||||
try {
|
|
||||||
const savedFileData = JSON.parse(localStorage.getItem('activeFiles') || '[]');
|
|
||||||
if (savedFileData.length > 0) {
|
|
||||||
// File restoration handled by FileContext
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('Failed to restore active files:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
restoreActiveFiles();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const handleToolSelect = useCallback(
|
const handleToolSelect = useCallback(
|
||||||
(id: string) => {
|
(id: string) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user