@@ -38,6 +38,10 @@ export class Drive implements Contents.IDrive {
3838 this . _serverSettings = ServerConnection . makeSettings ( ) ;
3939 this . _name = options . name ?? '' ;
4040 this . _drivesList = options . drivesList ?? [ ] ;
41+
42+ this . fileChanged . connect ( ( sender , args ) => {
43+ console . log ( 'fileChanged' , args ) ;
44+ } ) ;
4145 }
4246
4347 /**
@@ -219,8 +223,11 @@ export class Drive implements Contents.IDrive {
219223 localPath : string ,
220224 options ?: Contents . IFetchOptions
221225 ) : Promise < Contents . IModel > {
226+ console . log ( '[DEBUG] get() called with localPath:' , localPath ) ;
222227 let data : Contents . IModel ;
223228
229+ const isFromClick = this . isUserInitiated ( ) ;
230+
224231 if ( localPath !== '' ) {
225232 console . log ( 'debug: IF get() called with localPath:' , localPath ) ;
226233 const currentDrive = extractCurrentDrive ( localPath , this . _drivesList ) ;
@@ -244,12 +251,13 @@ export class Drive implements Contents.IDrive {
244251 registeredFileTypes : this . _registeredFileTypes
245252 } ) ;
246253
247- this . _loadingContents . emit ( {
248- type : 'loading' ,
249- path : localPath ,
250- driveName : this . _name ,
251- itemType : result . isDir ? 'directory' : 'file'
252- } ) ;
254+ isFromClick &&
255+ this . _loadingContents . emit ( {
256+ type : 'loading' ,
257+ path : localPath ,
258+ driveName : this . _name ,
259+ itemType : result . isDir ? 'directory' : 'file'
260+ } ) ;
253261
254262 data = {
255263 name : result . isDir
@@ -277,12 +285,13 @@ export class Drive implements Contents.IDrive {
277285 } else {
278286 console . log ( 'debug: ELSE get() called with localPath:' , localPath ) ;
279287
280- this . _loadingContents . emit ( {
281- type : 'loading' ,
282- path : localPath ,
283- driveName : this . _name ,
284- itemType : 'directory'
285- } ) ;
288+ isFromClick &&
289+ this . _loadingContents . emit ( {
290+ type : 'loading' ,
291+ path : localPath ,
292+ driveName : this . _name ,
293+ itemType : 'directory'
294+ } ) ;
286295
287296 // retriving list of contents from root
288297 // in our case: list available drives
@@ -326,15 +335,34 @@ export class Drive implements Contents.IDrive {
326335 }
327336
328337 Contents . validateContentsModel ( data ) ;
329- this . _loadingContents . emit ( {
330- type : 'loaded' ,
331- path : localPath ,
332- driveName : this . _name ,
333- itemType : 'directory'
334- } ) ;
338+
339+ isFromClick &&
340+ this . _loadingContents . emit ( {
341+ type : 'loaded' ,
342+ path : localPath ,
343+ driveName : this . _name ,
344+ itemType : 'directory'
345+ } ) ;
335346 return data ;
336347 }
337348
349+ // This is dumb?
350+ isUserInitiated ( ) {
351+ const stack = new Error ( ) . stack ;
352+
353+ // Check if it's from a click event by examining the call stack
354+ const isFromClick =
355+ stack ?. includes ( 'evtDblClick' ) ||
356+ stack ?. includes ( 'handleOpen' ) ||
357+ stack ?. includes ( '_evtClick' ) ;
358+
359+ console . log ( '[DEBUG] Call stack analysis:' ) ;
360+ console . log ( ' - Is from click event:' , isFromClick ) ;
361+ console . log ( ' - Call stack:' , stack ?. split ( '\n' ) . join ( '\n ' ) ) ;
362+
363+ return isFromClick ;
364+ }
365+
338366 /**
339367 * Create a new untitled file or directory in the specified directory path.
340368 *
0 commit comments