mirror of
https://github.com/zadam/trilium.git
synced 2026-01-06 06:34:25 +01:00
feat(client/pdf): filter out view config by fingerprint
This commit is contained in:
parent
ebf725c949
commit
84425e86e9
@ -2,10 +2,16 @@ export default function interceptViewHistory() {
|
|||||||
const originalSetItem = Storage.prototype.setItem;
|
const originalSetItem = Storage.prototype.setItem;
|
||||||
Storage.prototype.setItem = function (key: string, value: string) {
|
Storage.prototype.setItem = function (key: string, value: string) {
|
||||||
if (key === "pdfjs.history") {
|
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({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-save-view-history",
|
type: "pdfjs-viewer-save-view-history",
|
||||||
data: value
|
data: JSON.stringify(history)
|
||||||
}, "*");
|
}, "*");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user