Closed zivnadel closed 1 year ago
I’ll Look into it.
I have fixed the two bugs that you mentioned. The first one was caused by a typo I made in the generateStateWithNewFolder
function, where I mistakenly replaced newFolderName
with newFileName
.
The second bug was caused by the checkIfItemNameIsFolder
function, which checked for the existence of files with a certain name throughout the system. I have now modified it to check for items by the provided name under a passed node (path) - in our use case, the focused item. Although I believe that this solution works well for now, we should consider passing the parent node when a folder is opened, not just when it is focused. If this indicator has already been implemented, please let me know.
@yonatanmgr I fixed the last bugs, and made some changes. The main change I did is that generateStateWithNewFile
, generateStateWithNewFolder
and itemExistsInParent
(which is the new version of checkIfItemNameIsFolder
, more about that below) now relate to the selectedFolder
and not focusedItem
. Other changes I made:
checkIfItemNameIsFolder
as itemExistsInParent
. It is pretty much doing the same, but now correct and more concise. Reference the comments in the function for more information.generateStateWithNewFile
and generateStateWithNewFolder
. The first if
check in those functions was redundant, since it was looking for the parent's path, which we don't need to look for now, as it is the key (or index
).
I have fixed several bugs in this Pull Request.
Firstly, I addressed issue #4. I fixed it by doing something similar to what @alex-laycalvert suggested there. I changed
if(focusedItem)
toif(focusedItem != -1)
ingenerateStateWithNewFolder
andgenerateStateWithNewFolder
(located inFileSystemHelpers.ts
). In my opinion, this change is more accurate becauseitem.index
will either be-1
or a string. Usingif(focusedItem >= 0)
would work but is less clear.Secondly, I addressed some bugs related to PR #22 regarding focusing a file. Since in that PR I changed the structure of the file system item (making the index and the object key the path of the file) it broke some stuff:
FileSystemHelpers.ts
)addFile
andaddFolder
functions (located inFileSystem.tsx
), the check for the existence of an item was broken because the key is no longer the name but the path. I implemented a new function inFileSystemHelpers.tsx
to make this check, now that the name is a property (data
) and not the object key.Important note: I have not yet adapted the
handleRenameItem
function (located inFileSystem.tsx
) to the changes in PR #22. Therefore, renaming will likely be broken when it is implemented. I will make sure to fix it as soon as possible.I believe these changes have resolved all known issues. However, if any further bugs are discovered, I will be sure to fix them as soon as possible.