feat(client/pdf): filter out view config by fingerprint

This commit is contained in:
Elian Doran 2025-12-29 16:06:30 +02:00
parent ebf725c949
commit 84425e86e9
No known key found for this signature in database

View File

@ -2,10 +2,16 @@ export default function interceptViewHistory() {
const originalSetItem = Storage.prototype.setItem;
Storage.prototype.setItem = function (key: string, value: string) {
if (key === "pdfjs.history") {
console.log(`Intercepted setting view history: ${key} = ${value}`);
// Parse the history and remove entries that are not relevant.
const history = JSON.parse(value);
const fingerprint = window.PDFViewerApplication?.pdfDocument?.fingerprints?.[0];
if (fingerprint) {
history.files = history.files.filter((file: any) => file.fingerprint === fingerprint);
}
window.parent.postMessage({
type: "pdfjs-viewer-save-view-history",
data: value
data: JSON.stringify(history)
}, "*");
return;
}