mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	using global one setInterval instead of scheduling setTimeout after each encryption operation (there can be many of them)
This commit is contained in:
		@@ -111,26 +111,26 @@ $("#encryptionPasswordForm").submit(function() {
 | 
				
			|||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getAes() {
 | 
					setInterval(function() {
 | 
				
			||||||
    globalLastEncryptionOperationDate = new Date();
 | 
					    if (globalLastEncryptionOperationDate !== null && new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionKeyTimeToLive) {
 | 
				
			||||||
 | 
					        globalEncryptionKey = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    setTimeout(function() {
 | 
					        if (globalNote.detail.encryption > 0) {
 | 
				
			||||||
        if (new Date().getTime() - globalLastEncryptionOperationDate.getTime() > globalEncryptionKeyTimeToLive) {
 | 
					            loadNote(globalNote.detail.note_id);
 | 
				
			||||||
            globalEncryptionKey = null;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (globalNote.detail.encryption > 0) {
 | 
					            for (const noteId of globalAllNoteIds) {
 | 
				
			||||||
                loadNote(globalNote.detail.note_id);
 | 
					                const note = getNodeByKey(noteId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                for (const noteId of globalAllNoteIds) {
 | 
					                if (note.data.encryption > 0) {
 | 
				
			||||||
                    const note = getNodeByKey(noteId);
 | 
					                    note.setTitle("[encrypted]");
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if (note.data.encryption > 0) {
 | 
					 | 
				
			||||||
                        note.setTitle("[encrypted]");
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }, globalEncryptionKeyTimeToLive + 1000);
 | 
					    }
 | 
				
			||||||
 | 
					}, 5000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function getAes() {
 | 
				
			||||||
 | 
					    globalLastEncryptionOperationDate = new Date();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return new aesjs.ModeOfOperation.ctr(globalEncryptionKey, new aesjs.Counter(5));
 | 
					    return new aesjs.ModeOfOperation.ctr(globalEncryptionKey, new aesjs.Counter(5));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user