@@ -58,15 +58,6 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
5858 this . __folderRemoved ( folder ) ;
5959 } , this ) ;
6060
61- osparc . store . Folders . getInstance ( ) . addListener ( "folderMoved" , e => {
62- const {
63- folder,
64- oldParentFolderId,
65- } = e . getData ( ) ;
66- this . __folderRemoved ( folder , oldParentFolderId ) ;
67- this . __folderAdded ( folder ) ;
68- } , this ) ;
69-
7061 osparc . store . Workspaces . getInstance ( ) . addListener ( "workspaceAdded" , e => {
7162 const workspace = e . getData ( ) ;
7263 this . __addWorkspace ( workspace ) ;
@@ -299,26 +290,22 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
299290 }
300291 } ,
301292
302- __folderRemoved : function ( folder , oldParentFolderId ) {
293+ __folderRemoved : function ( folder ) {
303294 // eslint-disable-next-line no-negated-condition
304- const parentModel = this . __getModel ( folder . getWorkspaceId ( ) , oldParentFolderId !== undefined ? oldParentFolderId : folder . getParentFolderId ( ) ) ;
295+ const parentModel = this . __getModel ( folder . getWorkspaceId ( ) , folder . getParentFolderId ( ) ) ;
305296 if ( parentModel ) {
306- console . log ( "folder removed: children" , parentModel . getChildren ( ) . toArray ( ) ) ;
307297 const idx = parentModel . getChildren ( ) . toArray ( ) . findIndex ( c => "getWorkspaceId" in c && folder . getWorkspaceId ( ) === c . getWorkspaceId ( ) && folder . getFolderId ( ) === c . getFolderId ( ) ) ;
308298 if ( idx > - 1 ) {
309299 parentModel . getChildren ( ) . removeAt ( idx ) ;
310300 }
311301 }
312302
313- if ( oldParentFolderId === undefined ) {
314- // it was removed, not moved
315- // remove it from the cached models
316- const modelFound = this . __getModel ( folder . getWorkspaceId ( ) , folder . getFolderId ( ) ) ;
317- if ( modelFound ) {
318- const index = this . __models . indexOf ( modelFound ) ;
319- if ( index > - 1 ) { // only splice array when item is found
320- this . __models . splice ( index , 1 ) ; // 2nd parameter means remove one item only
321- }
303+ // remove it from the cached models
304+ const modelFound = this . __getModel ( folder . getWorkspaceId ( ) , folder . getFolderId ( ) ) ;
305+ if ( modelFound ) {
306+ const index = this . __models . indexOf ( modelFound ) ;
307+ if ( index > - 1 ) { // only splice array when item is found
308+ this . __models . splice ( index , 1 ) ; // 2nd parameter means remove one item only
322309 }
323310 }
324311 } ,
0 commit comments