You've already forked joplin
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:
@ -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 };
|
Reference in New Issue
Block a user