You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Api: Do not return deleted notes in folders/:id/notes call
This commit is contained in:
		| @@ -25,6 +25,34 @@ describe('routes/folders', () => { | ||||
| 		expect(page.items[0].id).toBe(folder2.id); | ||||
| 	}); | ||||
|  | ||||
| 	test('should not include deleted folders in GET folders/:id/notes call', async () => { | ||||
| 		const api = new Api(); | ||||
| 		const folder = await Folder.save({}); | ||||
| 		const note1 = await Note.save({ parent_id: folder.id }); | ||||
| 		const note2 = await Note.save({ parent_id: folder.id }); | ||||
|  | ||||
| 		{ | ||||
| 			const notes = await api.route(RequestMethod.GET, `folders/${folder.id}/notes`); | ||||
| 			expect(notes.items.length).toBe(2); | ||||
| 		} | ||||
|  | ||||
| 		await Note.delete(note1.id, { toTrash: true }); | ||||
|  | ||||
| 		{ | ||||
| 			const notes = await api.route(RequestMethod.GET, `folders/${folder.id}/notes`); | ||||
| 			expect(notes.items.length).toBe(1); | ||||
| 			expect(notes.items[0].id).toBe(note2.id); | ||||
| 		} | ||||
|  | ||||
| 		// const tree = await api.route(RequestMethod.GET, 'folders', { as_tree: 1 }); | ||||
| 		// expect(tree.length).toBe(1); | ||||
| 		// expect(tree[0].id).toBe(folder2.id); | ||||
|  | ||||
| 		// const page = await api.route(RequestMethod.GET, 'folders'); | ||||
| 		// expect(page.items.length).toBe(1); | ||||
| 		// expect(page.items[0].id).toBe(folder2.id); | ||||
| 	}); | ||||
|  | ||||
| 	test('should be able to delete to trash', async () => { | ||||
| 		const api = new Api(); | ||||
| 		const folder1 = await Folder.save({}); | ||||
|   | ||||
| @@ -25,7 +25,7 @@ export default async function(request: Request, id: string = null, link: string | ||||
| 	if (request.method === RequestMethod.GET && id) { | ||||
| 		if (link && link === 'notes') { | ||||
| 			const folder = await Folder.load(id); | ||||
| 			return paginatedResults(BaseModel.TYPE_NOTE, request, { sql: 'parent_id = ?', params: [folder.id] }); | ||||
| 			return paginatedResults(BaseModel.TYPE_NOTE, request, { sql: 'parent_id = ? AND deleted_time = 0', params: [folder.id] }); | ||||
| 		} else if (link) { | ||||
| 			throw new ErrorNotFound(); | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user