mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-08 13:06:15 +02:00
Desktop: Fixes #11226: Fix reordering notes in custom sort order when some notes are deleted (#11592)
This commit is contained in:
parent
e70efcbd60
commit
4d827afccb
@ -1030,6 +1030,7 @@ export default class Note extends BaseItem {
|
|||||||
FROM notes
|
FROM notes
|
||||||
WHERE
|
WHERE
|
||||||
is_conflict = 0
|
is_conflict = 0
|
||||||
|
AND deleted_time = 0
|
||||||
${showCompletedTodos ? '' : 'AND todo_completed = 0'}
|
${showCompletedTodos ? '' : 'AND todo_completed = 0'}
|
||||||
AND parent_id = ?
|
AND parent_id = ?
|
||||||
`;
|
`;
|
||||||
|
@ -282,4 +282,34 @@ describe('models/Note_CustomSortOrder', () => {
|
|||||||
expect(resortedNotes3[5].id).toBe(resortedNotes2[5].id);
|
expect(resortedNotes3[5].id).toBe(resortedNotes2[5].id);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should account for items in the trash', async () => {
|
||||||
|
const folder1 = await Folder.save({});
|
||||||
|
|
||||||
|
const notes = [];
|
||||||
|
notes.push(await Note.save({ order: 1003, parent_id: folder1.id, deleted_time: 1 })); await time.msleep(2);
|
||||||
|
notes.push(await Note.save({ order: 1002, parent_id: folder1.id })); await time.msleep(2);
|
||||||
|
notes.push(await Note.save({ order: 1001, parent_id: folder1.id })); await time.msleep(2);
|
||||||
|
notes.push(await Note.save({ order: 1000, parent_id: folder1.id })); await time.msleep(2);
|
||||||
|
|
||||||
|
const sortedNoteIds = async () => {
|
||||||
|
const notes = await Note.previews(folder1.id, {
|
||||||
|
fields: ['id', 'order', 'user_created_time', 'is_todo', 'todo_completed'],
|
||||||
|
order: Note.customOrderByColumns(),
|
||||||
|
});
|
||||||
|
return notes.map(note => note.id);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Should sort items correctly initially, with deleted items omitted
|
||||||
|
expect(await sortedNoteIds()).toEqual([
|
||||||
|
notes[1].id, notes[2].id, notes[3].id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Move a note to the end
|
||||||
|
await Note.insertNotesAt(folder1.id, [notes[1].id], 3, true, true);
|
||||||
|
|
||||||
|
// Should correctly reorder notes
|
||||||
|
expect(await sortedNoteIds()).toEqual([
|
||||||
|
notes[2].id, notes[3].id, notes[1].id,
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user