File tree 1 file changed +3
-4
lines changed
1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ export interface IResourcePageProps {
154
154
155
155
const basename = ( path : string ) : string => {
156
156
const parts = path . split ( "/" ) ;
157
- return parts . at ( - 1 ) || "" ;
157
+ return parts . length > 0 ? parts [ parts . length - 1 ] : ""
158
158
} ;
159
159
160
160
const flattenFSStateToFileStatusArray = ( {
@@ -321,8 +321,7 @@ export const ResourcePage: React.FC<ResourcePageProps> = (props) => {
321
321
} = actionData . payload as OpenFilesFileStatusPayload ;
322
322
323
323
if ( targetFile ?. isDir ) {
324
- const leafDir =
325
- currentDirChain . at ( - 1 ) || ( { id : "" , name : "" } as FileData ) ;
324
+ const leafDir = currentDirChain . length > 0 ? currentDirChain [ currentDirChain . length - 1 ] : ( { id : "" , name : "" } as FileData ) ;
326
325
327
326
if ( targetFile . id . length > leafDir . id . length ) {
328
327
// navigate down the file tree
@@ -463,7 +462,7 @@ export const ResourcePage: React.FC<ResourcePageProps> = (props) => {
463
462
] ;
464
463
465
464
useEffect ( ( ) => {
466
- const leafDir = currentDirChain . at ( - 1 ) || rootDir ;
465
+ const leafDir = currentDirChain . length > 0 ? currentDirChain [ currentDirChain . length - 1 ] : rootDir ;
467
466
// update files in view
468
467
const newFiles = createFilesArray ( leafDir , files ) ;
469
468
setCurrentFiles ( newFiles ) ;
You can’t perform that action at this time.
0 commit comments