File tree 1 file changed +28
-0
lines changed
arduino-ide-extension/src/browser/widgets/cloud-sketchbook
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';
32
32
import { ArduinoPreferences } from '../../arduino-preferences' ;
33
33
import { SketchesServiceClientImpl } from '../../../common/protocol/sketches-service-client-impl' ;
34
34
import { FileStat } from '@theia/filesystem/lib/common/files' ;
35
+ import { WorkspaceNode } from '@theia/navigator/lib/browser/navigator-tree' ;
35
36
36
37
const MESSAGE_TIMEOUT = 5 * 1000 ;
37
38
const deepmerge = require ( 'deepmerge' ) . default ;
@@ -265,6 +266,33 @@ export class CloudSketchbookTree extends SketchbookTree {
265
266
}
266
267
}
267
268
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
+
268
296
/**
269
297
* Retrieve fileStats for the given node, merging the local and remote childrens
270
298
* Local children take prevedence over remote ones
You can’t perform that action at this time.
0 commit comments