Don't cache embedded GEDCOM in sessionStorage#308
Merged
Conversation
Owner
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Don't cache embedded GEDCOM in sessionStorage
Summary
Embedded mode receives a fresh GEDCOM from the parent window on every load, so persisting it to
sessionStorageunder a constant key only ever serves a stale copy. This adds auseSessionCacheopt-out toloadGedcom()/prepareData()and has the embedded data source opt out, so embedded data is never read from or written to the session cache.Background
The in-memory store added in #296 already covers within-tab navigation, and the
ready/parent_readyhandshake means a page reload re-runs and the parent re-sends the GEDCOM. For embedded mode thesessionStoragelayer therefore adds nothing — it's redundant with the handshake and the in-memory store.It's also actively wrong when the GEDCOM references resources tied to the parent document. Embedded payloads can inline object URLs (
blob:/data:) that become invalid once the previous document is gone.loadGedcom()caches the prepared data under the constant keyembedded, andprepareData()'s existing guard only skips the write when a non-empty uploaded-images map is present — embedded mode passes an empty map (URLs are inlined in the GEDCOM text), so the guard didn't apply. On the next load the cached copy was served with dead object URLs and images broke until a hard refresh.Change
loadGedcom()/prepareData()take an optionaluseSessionCache(defaulttrue), gating both the read and the write.EmbeddedDataSourcecallsloadGedcom('embedded', onProgress, { useSessionCache: false }).No behavior change for any other data source — uploaded files still use the default (cache on). The in-memory store continues to serve within-tab navigation; a reload repopulates it via the handshake.
Testing
load_data_store.spec.ts: caching happens by default, and withuseSessionCache: falsea stale entry is neither served nor overwritten.npm run lint,tsc, andnpm test(jest) all pass locally.How I hit this
I run Topola Viewer behind a reverse proxy that also serves Gramps Web on the same origin; the GEDCOM is delivered to the embedded viewer via the Gramps Web API. After a reload, images failed to load until a hard refresh — the stale
embeddedcache entry was the cause.