@@ -2,7 +2,6 @@ import * as Constants from '../../constants/fs'
22import * as EngineGen from '../engine-gen-gen'
33import * as FsGen from '../fs-gen'
44import * as ConfigGen from '../config-gen'
5- import * as I from 'immutable'
65import * as RPCTypes from '../../constants/types/rpc-gen'
76import * as Saga from '../../util/saga'
87import * as Flow from '../../util/flow'
@@ -248,12 +247,13 @@ const getPrefetchStatusFromRPC = (
248247 case RPCTypes . PrefetchStatus . notStarted :
249248 return Constants . prefetchNotStarted
250249 case RPCTypes . PrefetchStatus . inProgress :
251- return Constants . makePrefetchInProgress ( {
250+ return {
251+ ...Constants . emptyPrefetchInProgress ,
252252 bytesFetched : prefetchProgress . bytesFetched ,
253253 bytesTotal : prefetchProgress . bytesTotal ,
254254 endEstimate : prefetchProgress . endEstimate ,
255255 startTime : prefetchProgress . start ,
256- } )
256+ }
257257 case RPCTypes . PrefetchStatus . complete :
258258 return Constants . prefetchComplete
259259 default :
@@ -271,24 +271,27 @@ const direntToMetadata = (d: RPCTypes.Dirent) => ({
271271 writable : d . writable ,
272272} )
273273
274- const makeEntry = ( d : RPCTypes . Dirent , children ?: Set < string > ) => {
274+ const makeEntry = ( d : RPCTypes . Dirent , children ?: Set < string > ) : Types . PathItem => {
275275 switch ( d . direntType ) {
276276 case RPCTypes . DirentType . dir :
277- return Constants . makeFolder ( {
277+ return {
278+ ...Constants . emptyFolder ,
278279 ...direntToMetadata ( d ) ,
279- children : I . Set ( children || [ ] ) || I . Set ( ) ,
280- progress : children ? Types . ProgressType . Loaded : undefined ,
281- } )
280+ children : new Set ( children || [ ] ) ,
281+ progress : children ? Types . ProgressType . Loaded : Types . ProgressType . Pending ,
282+ } as Types . PathItem
282283 case RPCTypes . DirentType . sym :
283- return Constants . makeSymlink ( {
284+ return {
285+ ...Constants . emptySymlink ,
284286 ...direntToMetadata ( d ) ,
285287 // TODO: plumb link target
286- } )
288+ } as Types . PathItem
287289 case RPCTypes . DirentType . file :
288290 case RPCTypes . DirentType . exec :
289- return Constants . makeFile ( direntToMetadata ( d ) )
290- default :
291- return Constants . makeUnknownPathItem ( direntToMetadata ( d ) )
291+ return {
292+ ...Constants . emptyFile ,
293+ ...direntToMetadata ( d ) ,
294+ } as Types . PathItem
292295 }
293296}
294297
@@ -348,28 +351,30 @@ function* folderList(_: TypedState, action: FsGen.FolderListLoadPayload) {
348351 if ( entry . type === Types . PathType . Folder && isRecursive && d . name . indexOf ( '/' ) < 0 ) {
349352 // Since we are loading with a depth of 2, first level directories are
350353 // considered "loaded".
351- return [ path , entry . set ( 'progress' , Types . ProgressType . Loaded ) ]
354+ entry . progress = Types . ProgressType . Loaded
355+ return [ path , entry ]
352356 }
353357 return [ path , entry ]
354358 }
355359
356360 // Get metadata fields of the directory that we just loaded from state to
357361 // avoid overriding them.
358362 const state : TypedState = yield * Saga . selectState ( )
359- const rootPathItem = state . fs . pathItems . get ( rootPath , Constants . unknownPathItem )
360- const rootFolder : Types . FolderPathItem = ( rootPathItem . type === Types . PathType . Folder
361- ? rootPathItem
362- : Constants . makeFolder ( { name : Types . getPathName ( rootPath ) } )
363- ) . withMutations ( f =>
364- f . set ( 'children' , I . Set ( childMap . get ( rootPath ) ) ) . set ( 'progress' , Types . ProgressType . Loaded )
365- )
363+ const rootPathItem = Constants . getPathItem ( state . fs . pathItems , rootPath )
364+ const rootFolder : Types . FolderPathItem = {
365+ ...( rootPathItem . type === Types . PathType . Folder
366+ ? rootPathItem
367+ : { ...Constants . emptyFolder , name : Types . getPathName ( rootPath ) } ) ,
368+ children : new Set ( childMap . get ( rootPath ) ) ,
369+ progress : Types . ProgressType . Loaded ,
370+ }
366371
367372 // @ts -ignore TODO fix this
368373 const pathItems : Array < [ Types . Path , Types . FolderPathItem ] > = [
369374 ...( Types . getPathLevel ( rootPath ) > 2 ? [ [ rootPath , rootFolder ] ] : [ ] ) ,
370375 ...entries . map ( direntToPathAndPathItem ) ,
371376 ]
372- yield Saga . put ( FsGen . createFolderListLoaded ( { path : rootPath , pathItems : I . Map ( pathItems ) } ) )
377+ yield Saga . put ( FsGen . createFolderListLoaded ( { path : rootPath , pathItems : new Map ( pathItems ) } ) )
373378 } catch ( error ) {
374379 yield makeRetriableErrorHandler ( action , rootPath ) ( error ) . map ( action => Saga . put ( action ) )
375380 }
@@ -535,11 +540,10 @@ function* loadPathMetadata(_: TypedState, action: FsGen.LoadPathMetadataPayload)
535540 } ,
536541 Constants . statWaitingKey
537542 )
538- let pathItem = makeEntry ( dirent )
539543 yield Saga . put (
540544 FsGen . createPathItemLoaded ( {
541545 path,
542- pathItem,
546+ pathItem : makeEntry ( dirent ) ,
543547 } )
544548 )
545549 } catch ( err ) {
@@ -613,19 +617,6 @@ const moveOrCopy = async (state: TypedState, action: FsGen.MovePayload | FsGen.C
613617const showMoveOrCopy = ( ) =>
614618 RouteTreeGen . createNavigateAppend ( { path : [ { props : { index : 0 } , selected : 'destinationPicker' } ] } )
615619
616- const closeDestinationPicker = ( ) => {
617- const currentRoutes = I . List ( )
618- // const currentRoutes = getPathProps(state.routeTree.routeState)
619- const firstDestinationPickerIndex = currentRoutes . findIndex ( ( { node} ) => node === 'destinationPicker' )
620- const newRoute = currentRoutes . reduce < Array < any > > (
621- ( routes , { node, props} , i ) =>
622- // node is never null
623- i < firstDestinationPickerIndex ? [ ...routes , { props, selected : node || '' } ] : routes ,
624- [ ]
625- )
626- return [ RouteTreeGen . createNavigateAppend ( { path : newRoute } ) ]
627- }
628-
629620// Can't rely on kbfsDaemonStatus.rpcStatus === 'waiting' as that's set by
630621// reducer and happens before this.
631622let waitForKbfsDaemonOnFly = false
@@ -724,7 +715,7 @@ const onNotifyFSOverallSyncSyncStatusChanged = (
724715 > = [
725716 FsGen . createOverallSyncStatusChanged ( {
726717 diskSpaceStatus,
727- progress : Constants . makeSyncingFoldersProgress ( action . payload . params . status . prefetchProgress ) ,
718+ progress : action . payload . params . status . prefetchProgress ,
728719 } ) ,
729720 ]
730721 // Only notify about the disk space status if it has changed.
@@ -927,7 +918,6 @@ function* fsSaga() {
927918 )
928919 yield * Saga . chainAction2 ( [ FsGen . move , FsGen . copy ] , moveOrCopy )
929920 yield * Saga . chainAction2 ( [ FsGen . showMoveOrCopy , FsGen . showIncomingShare ] , showMoveOrCopy )
930- yield * Saga . chainAction2 ( FsGen . closeDestinationPicker , closeDestinationPicker )
931921 yield * Saga . chainAction2 (
932922 [ ConfigGen . installerRan , ConfigGen . loggedIn , FsGen . waitForKbfsDaemon ] ,
933923 waitForKbfsDaemon
0 commit comments