mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	handling of cloned notes moved to backend which should fix some annoying behaviors
This commit is contained in:
		
							
								
								
									
										13
									
								
								src/notes.py
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/notes.py
									
									
									
									
									
								
							| @@ -12,14 +12,25 @@ class Notes(Resource): | |||||||
|     def get(self, note_id): |     def get(self, note_id): | ||||||
|         execute("update options set opt_value = ? where opt_name = 'start_node'", [note_id]) |         execute("update options set opt_value = ? where opt_name = 'start_node'", [note_id]) | ||||||
|  |  | ||||||
|  |         detail = getSingleResult("select * from notes where note_id = ?", [note_id]) | ||||||
|  |  | ||||||
|  |         if detail['note_clone_id']: | ||||||
|  |             note_id = detail['note_clone_id'] | ||||||
|  |             detail = getSingleResult("select * from notes where note_id = ?", [note_id]) | ||||||
|  |  | ||||||
|         return { |         return { | ||||||
|             'detail': getSingleResult("select * from notes where note_id = ?", [note_id]), |             'detail': detail, | ||||||
|             'formatting': getResults("select * from formatting where note_id = ? order by note_offset", [note_id]), |             'formatting': getResults("select * from formatting where note_id = ? order by note_offset", [note_id]), | ||||||
|             'links': getResults("select * from links where note_id = ? order by note_offset", [note_id]), |             'links': getResults("select * from links where note_id = ? order by note_offset", [note_id]), | ||||||
|             'images': getResults("select * from images where note_id = ? order by note_offset", [note_id]) |             'images': getResults("select * from images where note_id = ? order by note_offset", [note_id]) | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     def put(self, note_id): |     def put(self, note_id): | ||||||
|  |         detail = getSingleResult("select * from notes where note_id = ?", [note_id]) | ||||||
|  |  | ||||||
|  |         if detail['note_clone_id']: | ||||||
|  |             note_id = detail['note_clone_id'] | ||||||
|  |  | ||||||
|         note = request.get_json(force=True) |         note = request.get_json(force=True) | ||||||
|  |  | ||||||
|         now = math.floor(time.time()) |         now = math.floor(time.time()) | ||||||
|   | |||||||
| @@ -133,8 +133,8 @@ function html2notecase(contents, note) { | |||||||
|                     lnk_text: linkMatch[0] |                     lnk_text: linkMatch[0] | ||||||
|                 }); |                 }); | ||||||
|  |  | ||||||
|                 console.log(linkMatch[0]); |                 // console.log(linkMatch[0]); | ||||||
|                 console.log(linkMatch[0].length); |                 // console.log(linkMatch[0].length); | ||||||
|  |  | ||||||
|                 index += linkMatch[0].length; |                 index += linkMatch[0].length; | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -42,14 +42,12 @@ function saveNoteIfChanged(callback) { | |||||||
|  |  | ||||||
|     note.detail.note_title = title; |     note.detail.note_title = title; | ||||||
|  |  | ||||||
|     const note_id = note.detail.is_clone ? note.detail.note_clone_id : note.detail.note_id; |  | ||||||
|  |  | ||||||
|     $.ajax({ |     $.ajax({ | ||||||
|         url: baseUrl + 'notes/' + note_id, |         url: baseUrl + 'notes/' + note.detail.note_id, | ||||||
|         type: 'PUT', |         type: 'PUT', | ||||||
|         data: JSON.stringify(note), |         data: JSON.stringify(note), | ||||||
|         contentType: "application/json", |         contentType: "application/json", | ||||||
|         success: function(result) { |         success: function() { | ||||||
|             isNoteChanged = false; |             isNoteChanged = false; | ||||||
|  |  | ||||||
|             message("Saved!"); |             message("Saved!"); | ||||||
| @@ -58,7 +56,7 @@ function saveNoteIfChanged(callback) { | |||||||
|                 callback(); |                 callback(); | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
|         error: function(result) { |         error: function() { | ||||||
|             error("Error saving the note!"); |             error("Error saving the note!"); | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
|   | |||||||
| @@ -135,9 +135,8 @@ $(function(){ | |||||||
|             source: notes, |             source: notes, | ||||||
|             activate: function(event, data){ |             activate: function(event, data){ | ||||||
|                 const node = data.node.data; |                 const node = data.node.data; | ||||||
|                 const noteId = node.is_clone ? node.note_clone_id : node.note_id; |  | ||||||
|  |  | ||||||
|                 saveNoteIfChanged(() => loadNote(noteId)); |                 saveNoteIfChanged(() => loadNote(node.note_id)); | ||||||
|             }, |             }, | ||||||
|             expand: function(event, data) { |             expand: function(event, data) { | ||||||
|                 setExpanded(data.node.key, true); |                 setExpanded(data.node.key, true); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user