From 8561201abc54d8067cd18305b4be8d3c78dab6f1 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 4 Aug 2020 21:57:08 +0200 Subject: [PATCH] invalidate note complement cache quickly after load --- src/public/app/services/tree_cache.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/public/app/services/tree_cache.js b/src/public/app/services/tree_cache.js index fe9ccc301..a620c82c9 100644 --- a/src/public/app/services/tree_cache.js +++ b/src/public/app/services/tree_cache.js @@ -288,6 +288,13 @@ class TreeCache { async getNoteComplement(noteId) { if (!this.noteComplementPromises[noteId]) { this.noteComplementPromises[noteId] = server.get('notes/' + noteId).then(row => new NoteComplement(row)); + + // we don't want to keep large payloads forever in memory so we clean that up quite quickly + // this cache is more meant to share the data between different components within one business transaction (e.g. loading of the note into the tab context and all the components) + // this is also a work around for missing invalidation after change + this.noteComplementPromises[noteId].then( + () => setTimeout(() => this.noteComplementPromises[noteId] = null, 1000) + ); } return await this.noteComplementPromises[noteId];