diff --git a/ElectronClient/gui/MainScreen.jsx b/ElectronClient/gui/MainScreen.jsx index 20da074fc45..f9c0a40562b 100644 --- a/ElectronClient/gui/MainScreen.jsx +++ b/ElectronClient/gui/MainScreen.jsx @@ -209,11 +209,18 @@ class MainScreenComponent extends React.Component { }, }); } else if (command.name === 'moveToFolder') { - const folderItems = this.props.folders; - const startFolders = folderItems - .map(a => { - return { key: a.id, value: a.id, label: a.title, indentDepth: a.parent_id == '' ? 0 : 1 }; - }); + + const startFolders = []; + const maxDepth = 20; + + const addOptions = (folders, depth) => { + for (let i = 0; i < folders.length; i++) { + const folder = folders[i]; + startFolders.push({ key: folder.id, value: folder.id, label: folder.title, indentDepth: depth }); + if (folder.children) addOptions(folder.children, (depth + 1) < maxDepth ? depth + 1 : maxDepth); + } + }; + addOptions(await Folder.allAsTree(), 0); this.setState({ promptOptions: {