mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-18 09:35:20 +02:00
9c98fb5312
* Adding node counts for folders and tags * Add unit tests * Fix count update when the tag list for a note is updated * Right align note counts and remove from the settings screen * Folder note count calculation update to include descendants * Update Setting.js * Change count style and fix click on counts * Fix tag/folder count update on delete/add note * Review updates
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
const Folder = require('lib/models/Folder.js');
|
|
const Setting = require('lib/models/Setting.js');
|
|
|
|
class FoldersScreenUtils {
|
|
static async allForDisplay(options = {}) {
|
|
const orderDir = Setting.value('folders.sortOrder.reverse') ? 'DESC' : 'ASC';
|
|
|
|
const folderOptions = Object.assign(
|
|
{},
|
|
{
|
|
caseInsensitive: true,
|
|
order: [
|
|
{
|
|
by: 'title',
|
|
dir: orderDir,
|
|
},
|
|
],
|
|
},
|
|
options
|
|
);
|
|
|
|
let folders = await Folder.all(folderOptions);
|
|
|
|
if (Setting.value('folders.sortOrder.field') === 'last_note_user_updated_time') {
|
|
folders = await Folder.orderByLastModified(folders, orderDir);
|
|
}
|
|
|
|
if (Setting.value('showNoteCounts')) {
|
|
await Folder.addNoteCounts(folders);
|
|
}
|
|
|
|
return folders;
|
|
}
|
|
|
|
static async refreshFolders() {
|
|
const folders = await this.allForDisplay({ includeConflictFolder: true });
|
|
|
|
this.dispatch({
|
|
type: 'FOLDER_UPDATE_ALL',
|
|
items: folders,
|
|
});
|
|
}
|
|
|
|
static scheduleRefreshFolders() {
|
|
if (this.scheduleRefreshFoldersIID_) clearTimeout(this.scheduleRefreshFoldersIID_);
|
|
|
|
this.scheduleRefreshFoldersIID_ = setTimeout(() => {
|
|
this.scheduleRefreshFoldersIID_ = null;
|
|
this.refreshFolders();
|
|
}, 1000);
|
|
}
|
|
}
|
|
|
|
module.exports = { FoldersScreenUtils };
|