@@ -252,16 +252,28 @@ export class Updater {
252252 } ;
253253
254254 refreshFiles = async ( ) : Promise < string > => {
255- const status = await this . setItems ( this . props . filesInfo . dirPath ) ;
255+ const status = await this . setItems ( this . props . filesInfo . dirPath , true ) ;
256256 if ( status !== "" ) {
257257 return status ;
258258 }
259259 } ;
260260
261- setItems = async ( dirParts : List < string > ) : Promise < string > => {
261+ setItems = async (
262+ dirParts : List < string > ,
263+ isRefreshing ?: boolean
264+ ) : Promise < string > => {
262265 const dirPath = dirParts . join ( "/" ) ;
263266 const listResp = await this . filesClient . list ( dirPath ) ;
264267
268+ // The listing result could be returned after user has been gone to another directory
269+ // isStillInThePath compares the listing one with the current one
270+ // TODO: in the long-term listing result should be ordered and canceled
271+ const isStillInThePath = dirPath === this . props . filesInfo . dirPath . join ( "/" ) ;
272+ if ( isRefreshing && ! isStillInThePath ) {
273+ // ignore the result
274+ return "" ;
275+ }
276+
265277 if ( listResp . status === 200 ) {
266278 this . props . filesInfo . dirPath = dirParts ;
267279 this . props . filesInfo . items = List < MetadataResp > ( listResp . data . metadatas ) ;
@@ -1037,7 +1049,7 @@ export class Updater {
10371049 reindex = async ( ) : Promise < string > => {
10381050 const resp = await this . filesClient . reindex ( ) ;
10391051 return resp . status === 200 ? "" : errServer ;
1040- }
1052+ } ;
10411053
10421054 hasResult = ( ) : boolean => {
10431055 return this . props . filesInfo . searchResults . size > 0 ;
0 commit comments