File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed 
arduino-ide-extension/src/browser/widgets/cloud-sketchbook Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import { firstToUpperCase } from '../../../common/utils';
3232import  {  ArduinoPreferences  }  from  '../../arduino-preferences' ; 
3333import  {  SketchesServiceClientImpl  }  from  '../../../common/protocol/sketches-service-client-impl' ; 
3434import  {  FileStat  }  from  '@theia/filesystem/lib/common/files' ; 
35+ import  {  WorkspaceNode  }  from  '@theia/navigator/lib/browser/navigator-tree' ; 
3536
3637const  MESSAGE_TIMEOUT  =  5  *  1000 ; 
3738const  deepmerge  =  require ( 'deepmerge' ) . default ; 
@@ -265,6 +266,33 @@ export class CloudSketchbookTree extends SketchbookTree {
265266    } 
266267  } 
267268
269+   async  resolveChildren ( parent : CompositeTreeNode ) : Promise < TreeNode [ ] >  { 
270+     return  ( await  super . resolveChildren ( parent ) ) . sort ( ( a ,  b )  =>  { 
271+       if  ( 
272+         WorkspaceNode . is ( parent )  && 
273+         FileStatNode . is ( a )  && 
274+         FileStatNode . is ( b ) 
275+       )  { 
276+         const  syncNodeA  = 
277+           CloudSketchbookTree . CloudSketchTreeNode . is ( a )  && 
278+           CloudSketchbookTree . CloudSketchTreeNode . isSynced ( a ) ; 
279+         const  syncNodeB  = 
280+           CloudSketchbookTree . CloudSketchTreeNode . is ( b )  && 
281+           CloudSketchbookTree . CloudSketchTreeNode . isSynced ( b ) ; 
282+ 
283+         const  syncComparison  =  Number ( syncNodeB )  -  Number ( syncNodeA ) ; 
284+ 
285+         // same sync status, compare on modified time 
286+         if  ( syncComparison  ===  0 )  { 
287+           return  ( a . fileStat . mtime  ||  0 )  -  ( b . fileStat . mtime  ||  0 ) ; 
288+         } 
289+         return  syncComparison ; 
290+       } 
291+ 
292+       return  0 ; 
293+     } ) ; 
294+   } 
295+ 
268296  /** 
269297   * Retrieve fileStats for the given node, merging the local and remote childrens 
270298   * Local children take prevedence over remote ones 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments