feat: enable persistent local archives and smart profile fallback

Key changes:
- Enabled full metadata caching for local folder archives, allowing them to load instantly from IndexedDB without re-uploading.
- Implemented oldest-image fallback for profiles missing an explicit profile picture.
- Restored folder-name-to-username detection for local archive uploads.
- Optimized scan indexing to track all image files for fallback use.
This commit is contained in:
ergosteur
2026-03-07 21:56:25 -05:00
parent 8809b7794b
commit 899e8dfbbb
3 changed files with 59 additions and 3 deletions
+32
View File
@@ -192,6 +192,37 @@ export default function App() {
}
}, [handleFiles, setAllPosts, setAllStories, setProfileMetadata, setIsScanning, setScanningPhase]);
const loadLocalCachedArchive = useCallback(async (archive: any) => {
console.log(`[Cache] Loading local archive from cache: ${archive.name}`);
setIsScanning(true);
setCurrentArchive(null);
setScanningPhase('Checking Cache');
try {
// Small delay for UI transition
await new Promise(resolve => setTimeout(resolve, 300));
setAllPosts(archive.posts || []);
setAllStories(archive.stories || []);
const profileMetadata = { ...archive.profileMetadata };
if (!profileMetadata.allProfilePics && archive.allProfilePics) {
profileMetadata.allProfilePics = archive.allProfilePics;
}
if (!profileMetadata.allProfilePics) {
profileMetadata.allProfilePics = profileMetadata.profilePic ? [profileMetadata.profilePic] : [];
}
setProfileMetadata(profileMetadata);
setVisiblePostsCount(90);
setIsScanning(false);
console.log(`[Cache] Local archive ${archive.name} restored from cache.`);
} catch (err) {
console.error('[Cache] Failed to restore local archive:', err);
setIsScanning(false);
}
}, [setAllPosts, setAllStories, setProfileMetadata, setIsScanning, setScanningPhase]);
const handleLocalFiles = (files: FileList | null) => { if (!files) return; const archiveFiles = Array.from(files).map(f => new LocalArchiveFile(f)); handleFiles(archiveFiles); };
const triggerFileSelect = () => fileInputRef.current?.click();
const loadMore = () => setVisiblePostsCount(prev => prev + 90);
@@ -279,6 +310,7 @@ export default function App() {
cachedArchives={cachedArchives}
onSelect={loadServerArchive}
onLocalSelect={triggerFileSelect}
onLocalCacheSelect={loadLocalCachedArchive}
onClearCache={clearCache}
isScanning={isScanning}
/>