1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Desktop: Resolves #206: Added support for sorting notebooks by title or last modified

This commit is contained in:
Laurent Cozic
2019-03-02 17:35:57 +00:00
parent 2256b0c5ec
commit 833d473268
8 changed files with 204 additions and 25 deletions

View File

@ -1,22 +1,39 @@
const Folder = require('lib/models/Folder.js');
const Setting = require('lib/models/Setting.js');
class FoldersScreenUtils {
static async refreshFolders() {
let initialFolders = await Folder.all({
const orderDir = Setting.value('folders.sortOrder.reverse') ? 'DESC' : 'ASC';
let folders = await Folder.all({
includeConflictFolder: true,
caseInsensitive: true,
order: [{
by: "title",
dir: "asc"
by: 'title',
dir: orderDir,
}]
});
if (Setting.value('folders.sortOrder.field') === 'last_note_user_updated_time') {
folders = await Folder.orderByLastModified(folders, orderDir);
}
this.dispatch({
type: 'FOLDER_UPDATE_ALL',
items: initialFolders,
items: folders,
});
}
static scheduleRefreshFolders() {
if (this.scheduleRefreshFoldersIID_) clearTimeout(this.scheduleRefreshFoldersIID_);
this.scheduleRefreshFoldersIID_ = setTimeout(() => {
this.scheduleRefreshFoldersIID_ = null;
this.refreshFolders();
}, 1000);
}
}
module.exports = { FoldersScreenUtils };