@@ -74,7 +74,7 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
7474
7575 osparc . store . Workspaces . getInstance ( ) . addListener ( "workspaceRemoved" , e => {
7676 const workspace = e . getData ( ) ;
77- this . __removeWorkspace ( workspace ) ;
77+ this . __workspaceRemoved ( workspace ) ;
7878 } , this ) ;
7979
8080 this . getSelection ( ) . addListener ( "change" , ( ) => {
@@ -227,7 +227,7 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
227227 this . __populateFolder ( workspaceModel , workspace . getWorkspaceId ( ) , null ) ;
228228 } ,
229229
230- __removeWorkspace : function ( workspace ) {
230+ __workspaceRemoved : function ( workspace ) {
231231 // remove it from the tree
232232 const sharedWorkspaceModel = this . __getModel ( - 1 , null ) ;
233233 const idx = sharedWorkspaceModel . getChildren ( ) . toArray ( ) . findIndex ( w => workspace . getWorkspaceId ( ) === w . getWorkspaceId ( ) ) ;
@@ -293,7 +293,19 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
293293 if ( parentModel ) {
294294 const idx = parentModel . getChildren ( ) . toArray ( ) . findIndex ( c => folder . getWorkspaceId ( ) === c . getWorkspaceId ( ) && folder . getFolderId ( ) === c . getFolderId ( ) ) ;
295295 if ( idx > - 1 ) {
296- parentModel . getChildren ( ) . toArray ( ) . splice ( idx , 1 ) ;
296+ parentModel . getChildren ( ) . removeAt ( idx ) ;
297+ }
298+ }
299+
300+ if ( oldParentFolderId !== undefined ) {
301+ // it was removed, not moved
302+ // remove it from the cached models
303+ const modelFound = this . __getModel ( folder . getWorkspaceId ( ) , folder . getParentFolderId ( ) ) ;
304+ if ( modelFound ) {
305+ const index = this . __models . indexOf ( modelFound ) ;
306+ if ( index > - 1 ) { // only splice array when item is found
307+ this . __models . splice ( index , 1 ) ; // 2nd parameter means remove one item only
308+ }
297309 }
298310 }
299311 } ,
0 commit comments