1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Clipper: Allow selecting a folder and fixed screenshot taking issue

This commit is contained in:
Laurent Cozic
2018-05-26 15:46:57 +01:00
parent d6c6ef20d4
commit 89b486a3ee
10 changed files with 246 additions and 56 deletions

View File

@@ -127,6 +127,34 @@ class Folder extends BaseItem {
return output;
}
static async allAsTree(options = null) {
const all = await this.all(options);
// https://stackoverflow.com/a/49387427/561309
function getNestedChildren(models, parentId) {
const nestedTreeStructure = [];
const length = models.length;
for (let i = 0; i < length; i++) {
const model = models[i];
if (model.parent_id == parentId) {
const children = getNestedChildren(models, model.id);
if (children.length > 0) {
model.children = children;
}
nestedTreeStructure.push(model);
}
}
return nestedTreeStructure;
}
return getNestedChildren(all, '');
}
static load(id) {
if (id == this.conflictFolderId()) return this.conflictFolder();
return super.load(id);