mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	wip
This commit is contained in:
		| @@ -123,7 +123,7 @@ class TreeCache { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     async reloadNotes(noteIds) { |     async reloadData(noteIds) { | ||||||
|         const resp = await server.post('tree/load', { noteIds }); |         const resp = await server.post('tree/load', { noteIds }); | ||||||
|  |  | ||||||
|         this.addResp(resp.notes, resp.branches, resp.attributes); |         this.addResp(resp.notes, resp.branches, resp.attributes); | ||||||
| @@ -224,6 +224,36 @@ class TreeCache { | |||||||
|  |  | ||||||
|         return child.parentToBranch[parentNoteId]; |         return child.parentToBranch[parentNoteId]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     syncDataListener({data}) {return; | ||||||
|  |         const noteIdsToRefresh = new Set(); | ||||||
|  |  | ||||||
|  |         data.filter(sync => sync.entityName === 'branches').forEach(sync => { | ||||||
|  |             const branch = this.branches[sync.entityId]; | ||||||
|  |             // we assume that the cache contains the old branch state and we add also the old parentNoteId | ||||||
|  |             // so that the old parent can also be updated | ||||||
|  |             noteIdsToRefresh.add(branch.parentNoteId); | ||||||
|  |  | ||||||
|  |             // this should then contain new parentNoteId for which we should also update the cache | ||||||
|  |             noteIdsToRefresh.add(sync.parentNoteId); | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         data.filter(sync => sync.entityName === 'notes').forEach(sync => noteIdsToRefresh.add(sync.entityId)); | ||||||
|  |  | ||||||
|  |         data.filter(sync => sync.entityName === 'note_reordering').forEach(sync => noteIdsToRefresh.add(sync.entityId)); | ||||||
|  |  | ||||||
|  |         data.filter(sync => sync.entityName === 'attributes').forEach(sync => { | ||||||
|  |             const note = treeCache.notes[sync.noteId]; | ||||||
|  |  | ||||||
|  |             if (note && note.__attributeCache) { | ||||||
|  |                 noteIdsToRefresh.add(sync.entityId); | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         if (noteIdsToRefresh.size > 0) { | ||||||
|  |             this.reloadNotes({noteIds: Array.from(noteIdsToRefresh)}); | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| const treeCache = new TreeCache(); | const treeCache = new TreeCache(); | ||||||
|   | |||||||
| @@ -88,12 +88,6 @@ class AttributesWidget extends StandardWidget { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     toggle(show) { |  | ||||||
|         console.trace("attributes toggle", show); |  | ||||||
|  |  | ||||||
|         super.toggle(show); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     syncDataListener({data}) { |     syncDataListener({data}) { | ||||||
|         if (data.find(sd => sd.entityName === 'attributes' && sd.noteId === this.tabContext.note.noteId)) { |         if (data.find(sd => sd.entityName === 'attributes' && sd.noteId === this.tabContext.note.noteId)) { | ||||||
|             // no need to invalidate attributes since the Attribute class listens to this as well |             // no need to invalidate attributes since the Attribute class listens to this as well | ||||||
|   | |||||||
| @@ -533,7 +533,7 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     syncDataListener({data}) { |     syncDataListener({data}) {return; | ||||||
|         const noteIdsToRefresh = new Set(); |         const noteIdsToRefresh = new Set(); | ||||||
|  |  | ||||||
|         // this has the problem that the former parentNoteId might not be invalidated |         // this has the problem that the former parentNoteId might not be invalidated | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user