Skip to content

Commit

Permalink
updated directories handling
Browse files Browse the repository at this point in the history
  • Loading branch information
molotgor committed Apr 12, 2024
1 parent 2984a14 commit fb63a8e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/components/JSONViewer/FileChoosing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,10 @@ const FileChoosing = ({
}, []);

const openDirectory = async (directoryName: string) => {
getLinks(`${directory}${directoryName}`);
getLinks(`${directoryName}`);
};

const closeModal = () => {
setDirectories([]);
setDirectory('');
setFiles([]);
close();
};

Expand All @@ -61,10 +58,10 @@ const FileChoosing = ({
setFiles([]);
if (directory === '') {
closeModal();
} else if (directory.indexOf('/') === directory.lastIndexOf('/')) {
} else if (directory.indexOf('\\') === directory.lastIndexOf('\\')) {
getLinks();
} else {
getLinks(`${directory.slice(0, directory.slice(0, -1).lastIndexOf('/') + 1)}`);
getLinks(`${directory.slice(0, directory.slice(0, -1).lastIndexOf('\\'))}`);
}
};

Expand Down Expand Up @@ -168,7 +165,7 @@ const FileChoosing = ({
key={index}
onClick={() => openDirectory(dir)}>
<div className='fileChoosing__directory-icon' />
{decodeURI(dir)}
{decodeURI(dir).replace(directory, '')}
</div>
))}
</>
Expand All @@ -184,7 +181,7 @@ const FileChoosing = ({
title={decodeURI(file)}
onClick={() => selectFile(file)}>
<div className='fileChoosing__file-icon' />
{decodeURI(file)}
{decodeURI(file).replace(directory, '')}
</div>
))}
</>
Expand Down

0 comments on commit fb63a8e

Please sign in to comment.