mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-08 17:51:20 +02:00
Result files are added to recents
This commit is contained in:
parent
96aa43860b
commit
aa41cbe75d
@ -122,8 +122,8 @@ function FileContextInner({
|
|||||||
|
|
||||||
// Helper functions for pinned files
|
// Helper functions for pinned files
|
||||||
const consumeFilesWrapper = useCallback(async (inputFileIds: FileId[], outputFiles: File[]): Promise<void> => {
|
const consumeFilesWrapper = useCallback(async (inputFileIds: FileId[], outputFiles: File[]): Promise<void> => {
|
||||||
return consumeFiles(inputFileIds, outputFiles, stateRef, filesRef, dispatch);
|
return consumeFiles(inputFileIds, outputFiles, stateRef, filesRef, dispatch, indexedDB);
|
||||||
}, []);
|
}, [indexedDB]);
|
||||||
|
|
||||||
// Helper to find FileId from File object
|
// Helper to find FileId from File object
|
||||||
const findFileId = useCallback((file: File): FileId | undefined => {
|
const findFileId = useCallback((file: File): FileId | undefined => {
|
||||||
|
@ -330,7 +330,8 @@ export async function consumeFiles(
|
|||||||
outputFiles: File[],
|
outputFiles: File[],
|
||||||
stateRef: React.MutableRefObject<FileContextState>,
|
stateRef: React.MutableRefObject<FileContextState>,
|
||||||
filesRef: React.MutableRefObject<Map<FileId, File>>,
|
filesRef: React.MutableRefObject<Map<FileId, File>>,
|
||||||
dispatch: React.Dispatch<FileContextAction>
|
dispatch: React.Dispatch<FileContextAction>,
|
||||||
|
indexedDB?: { saveFile: (file: File, fileId: FileId, existingThumbnail?: string) => Promise<any> } | null
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (DEBUG) console.log(`📄 consumeFiles: Processing ${inputFileIds.length} input files, ${outputFiles.length} output files`);
|
if (DEBUG) console.log(`📄 consumeFiles: Processing ${inputFileIds.length} input files, ${outputFiles.length} output files`);
|
||||||
|
|
||||||
@ -362,16 +363,27 @@ export async function consumeFiles(
|
|||||||
record.processedFile = createProcessedFile(pageCount, thumbnail);
|
record.processedFile = createProcessedFile(pageCount, thumbnail);
|
||||||
}
|
}
|
||||||
|
|
||||||
return record;
|
return { record, file, fileId, thumbnail };
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Persist output files to IndexedDB if available
|
||||||
|
if (indexedDB) {
|
||||||
|
await Promise.all(outputFileRecords.map(async ({ file, fileId, thumbnail }) => {
|
||||||
|
try {
|
||||||
|
await indexedDB.saveFile(file, fileId, thumbnail);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to persist output file to IndexedDB:', file.name, error);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// Dispatch the consume action
|
// Dispatch the consume action
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'CONSUME_FILES',
|
type: 'CONSUME_FILES',
|
||||||
payload: {
|
payload: {
|
||||||
inputFileIds,
|
inputFileIds,
|
||||||
outputFileRecords
|
outputFileRecords: outputFileRecords.map(({ record }) => record)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user