1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixed: The side bar was being refreshed too frequently. Fixed: Order of notebooks with sub-notebooks was sometimes incorrect when sorting by last updated time.

This commit is contained in:
Laurent Cozic 2019-03-10 21:16:05 +00:00
parent 23e6e6e69d
commit 68fbe8125e
3 changed files with 33 additions and 2 deletions

View File

@ -99,6 +99,30 @@ describe('models_Folder', function() {
expect(folders[0].id).toBe(f1.id);
expect(folders[1].id).toBe(f3.id);
expect(folders[2].id).toBe(f2.id);
let n2 = await Note.save({ title: 'note2', parent_id: f2.id });
folders = await Folder.orderByLastModified(await Folder.all(), 'desc');
expect(folders[0].id).toBe(f2.id);
expect(folders[1].id).toBe(f1.id);
expect(folders[2].id).toBe(f3.id);
await Note.save({ id: n1.id, title: 'note1 MOD' });
folders = await Folder.orderByLastModified(await Folder.all(), 'desc');
expect(folders[0].id).toBe(f1.id);
expect(folders[1].id).toBe(f3.id);
expect(folders[2].id).toBe(f2.id);
let f4 = await Folder.save({ title: "folder4", parent_id: f1.id }); await sleep(0.1);
let n3 = await Note.save({ title: 'note3', parent_id: f4.id });
folders = await Folder.orderByLastModified(await Folder.all(), 'desc');
expect(folders.length).toBe(4);
expect(folders[0].id).toBe(f4.id);
expect(folders[1].id).toBe(f1.id);
expect(folders[2].id).toBe(f3.id);
expect(folders[3].id).toBe(f2.id);
}));
});

View File

@ -310,7 +310,9 @@ class BaseApplication {
SearchEngine.instance().scheduleSyncTables();
}
if (this.hasGui() && ["FOLDER_UPDATE_ONE", "FOLDER_UPDATE_ALL"].indexOf(action.type) >= 0) {
// Don't add FOLDER_UPDATE_ALL as refreshFolders() is calling it too, which
// would cause the sidebar to refresh all the time.
if (this.hasGui() && ["FOLDER_UPDATE_ONE"].indexOf(action.type) >= 0) {
refreshFolders = true;
}

View File

@ -134,7 +134,12 @@ class Folder extends BaseItem {
const parent = findFolderParent(folderId);
if (!parent) return;
folderIdToTime[parent.id] = folderIdToTime[folderId];
if (folderIdToTime[parent.id] && folderIdToTime[parent.id] >= folderIdToTime[folderId]) {
// Don't change so that parent has the same time as the last updated child
} else {
folderIdToTime[parent.id] = folderIdToTime[folderId];
}
applyChildTimeToParent(parent.id);
}