mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	when reloading tree after sync, decrypt tree items if in encryption context
This commit is contained in:
		| @@ -72,14 +72,10 @@ function computeScrypt(password, salt, callback) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
| $("#encryption-password-form").submit(() => { | function decryptTreeItems() { | ||||||
|     const password = $("#encryption-password").val(); |     if (!isEncryptionAvailable()) { | ||||||
|     $("#encryption-password").val(""); |         return; | ||||||
|  |     } | ||||||
|     getDataKey(password).then(key => { |  | ||||||
|         $("#encryption-password-dialog").dialog("close"); |  | ||||||
|  |  | ||||||
|         globalDataKey = key; |  | ||||||
|  |  | ||||||
|     for (const noteId of globalAllNoteIds) { |     for (const noteId of globalAllNoteIds) { | ||||||
|         const note = getNodeByKey(noteId); |         const note = getNodeByKey(noteId); | ||||||
| @@ -90,6 +86,18 @@ $("#encryption-password-form").submit(() => { | |||||||
|             note.setTitle(title); |             note.setTitle(title); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | $("#encryption-password-form").submit(() => { | ||||||
|  |     const password = $("#encryption-password").val(); | ||||||
|  |     $("#encryption-password").val(""); | ||||||
|  |  | ||||||
|  |     getDataKey(password).then(key => { | ||||||
|  |         $("#encryption-password-dialog").dialog("close"); | ||||||
|  |  | ||||||
|  |         globalDataKey = key; | ||||||
|  |  | ||||||
|  |         decryptTreeItems(); | ||||||
|  |  | ||||||
|         if (globalEncryptionDeferred !== null) { |         if (globalEncryptionDeferred !== null) { | ||||||
|             globalEncryptionDeferred.resolve(); |             globalEncryptionDeferred.resolve(); | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| function checkStatus() { | async function checkStatus() { | ||||||
|     $.ajax({ |     const resp = await $.ajax({ | ||||||
|         url: baseApiUrl + 'status', |         url: baseApiUrl + 'status', | ||||||
|         type: 'POST', |         type: 'POST', | ||||||
|         contentType: "application/json", |         contentType: "application/json", | ||||||
| @@ -8,18 +8,6 @@ function checkStatus() { | |||||||
|             currentNoteId: globalCurrentNote ? globalCurrentNote.detail.note_id : null, |             currentNoteId: globalCurrentNote ? globalCurrentNote.detail.note_id : null, | ||||||
|             currentNoteDateModified: globalCurrentNoteLoadTime |             currentNoteDateModified: globalCurrentNoteLoadTime | ||||||
|         }), |         }), | ||||||
|         success: resp => { |  | ||||||
|             if (resp.changedTree) { |  | ||||||
|                 loadTree().then(resp => { |  | ||||||
|                     console.log("Reloading tree because of background changes"); |  | ||||||
|  |  | ||||||
|                     // this will also reload the note content |  | ||||||
|                     globalTree.fancytree('getTree').reload(resp.notes); |  | ||||||
|                 }); |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|             $("#changesToPushCount").html(resp.changesToPushCount); |  | ||||||
|         }, |  | ||||||
|         statusCode: { |         statusCode: { | ||||||
|             401: () => { |             401: () => { | ||||||
|                 // if the user got logged out then we should display the page |                 // if the user got logged out then we should display the page | ||||||
| @@ -32,6 +20,19 @@ function checkStatus() { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     if (resp.changedTree) { | ||||||
|  |         const treeResp = await loadTree(); | ||||||
|  |  | ||||||
|  |         console.log("Reloading tree because of background changes"); | ||||||
|  |  | ||||||
|  |         // this will also reload the note content | ||||||
|  |         await globalTree.fancytree('getTree').reload(treeResp.notes); | ||||||
|  |  | ||||||
|  |         decryptTreeItems(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     $("#changesToPushCount").html(resp.changesToPushCount); | ||||||
| } | } | ||||||
|  |  | ||||||
| setInterval(checkStatus, 5 * 1000); | setInterval(checkStatus, 5 * 1000); | ||||||
		Reference in New Issue
	
	Block a user