Hydrate session PDF byte stores on engine mount.
Create PdfByteStore with sessionId (IndexedDB) and re-render after hydrate so the viewer gets live blob URLs after reload.
This commit is contained in:
parent
664d7da100
commit
a69e5d7881
2 changed files with 19 additions and 1 deletions
|
|
@ -153,6 +153,23 @@ export function EngineProvider({
|
|||
return attachPersister(engine, { key: snapshotKey });
|
||||
}, [engine, injected, snapshotKey, activeDocKey]);
|
||||
|
||||
// Rehydrate PDF bytes from IndexedDB (session-scoped). Snapshot restore
|
||||
// only brings back metadata; without this the viewer points at a dead
|
||||
// blob / fake fixture path and PDF.js reports "Invalid PDF structure".
|
||||
useEffect(() => {
|
||||
if (injected) return;
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
await byteStore.hydrate();
|
||||
if (!cancelled) {
|
||||
setEngineRevision((n) => n + 1);
|
||||
}
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [byteStore, injected, sessionId]);
|
||||
|
||||
// Persist the active-document pointer alongside the engine snapshot so a
|
||||
// reload lands the user back where they were.
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,8 @@ export function SessionProvider({
|
|||
(sessionId: SessionId) => {
|
||||
let store = byteStores.get(sessionId);
|
||||
if (!store) {
|
||||
store = createPdfByteStore();
|
||||
// sessionId enables IndexedDB mirror so PDF bytes survive reloads.
|
||||
store = createPdfByteStore({ sessionId });
|
||||
byteStores.set(sessionId, store);
|
||||
}
|
||||
return store;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue