Remive indexxedb removal on clear files

This commit is contained in:
Reece Browne 2025-08-26 09:23:36 +01:00
parent d66b6a1fbc
commit bb13df2b92
3 changed files with 15 additions and 5 deletions

View File

@ -231,10 +231,10 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({
const handleInsertFileAfter = useCallback((e: React.MouseEvent) => { const handleInsertFileAfter = useCallback((e: React.MouseEvent) => {
e.stopPropagation(); e.stopPropagation();
if (onInsertFiles) { if (onInsertFiles) {
// Open file manager modal with custom handler for page insertion // Open file manager modal with custom handler for page insertion
openFilesModal({ openFilesModal({
insertAfterPage: page.pageNumber, insertAfterPage: page.pageNumber,
customHandler: (files: File[], insertAfterPage?: number) => { customHandler: (files: File[], insertAfterPage?: number) => {
if (insertAfterPage !== undefined) { if (insertAfterPage !== undefined) {
@ -364,7 +364,7 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({
}} }}
> >
{page.isBlankPage ? ( {page.isBlankPage ? (
<div style={{ <div style={{
width: '100%', width: '100%',
height: '100%', height: '100%',
display: 'flex', display: 'flex',
@ -406,7 +406,7 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({
size="sm" size="sm"
fw={500} fw={500}
style={{ style={{
color: 'white', // Keep white for page numbers as they have colored backgrounds color: 'var(--mantine-color-white)', // Use theme token for consistency
position: 'absolute', position: 'absolute',
top: 5, top: 5,
left: 5, left: 5,

View File

@ -167,7 +167,16 @@ function FileContextInner({
filesRef.current.clear(); filesRef.current.clear();
dispatch({ type: 'RESET_CONTEXT' }); dispatch({ type: 'RESET_CONTEXT' });
// Clear IndexedDB if enabled // Don't clear IndexedDB automatically - only clear in-memory state
// IndexedDB should only be cleared when explicitly requested by user
},
clearAllData: async () => {
// First clear all files from memory
lifecycleManager.cleanupAllFiles();
filesRef.current.clear();
dispatch({ type: 'RESET_CONTEXT' });
// Then clear IndexedDB storage
if (indexedDB && enablePersistence) { if (indexedDB && enablePersistence) {
try { try {
await indexedDB.clearAll(); await indexedDB.clearAll();

View File

@ -224,6 +224,7 @@ export interface FileContextActions {
updateFileRecord: (id: FileId, updates: Partial<FileRecord>) => void; updateFileRecord: (id: FileId, updates: Partial<FileRecord>) => void;
reorderFiles: (orderedFileIds: FileId[]) => void; reorderFiles: (orderedFileIds: FileId[]) => void;
clearAllFiles: () => Promise<void>; clearAllFiles: () => Promise<void>;
clearAllData: () => Promise<void>;
// File pinning // File pinning
pinFile: (file: File) => void; pinFile: (file: File) => void;