Skip to content

Fix needs saving mark for renamed: Fixes #576 #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jareddonovan
Copy link
Contributor

Before your pull request is reviewed and merged, please ensure that:

  • there are no linting errors -- npm run lint (there are linting errors, but not in the files I have touched.)
  • your code is in a uniquely-named feature branch and has been rebased on top of the latest master. If you're asked to make more changes, make sure you rebase onto master then too!
  • your pull request is descriptively named and links to an issue number, i.e. Fixes #576

This is an attempt at fixing the problem described in #576, which is that after a file in a project has been renamed, the 'needs-saving' marker is not cleared after saving. I'm mainly adding this pull request to show that it fixes the problem, but I don't think it's the best code. If I was more familiar with the lodash library, I would try and use one of the functions provided by that rather than writing my own custom comparison function.

Another option is to look at the parts of the code that set the 'isEditingName' and 'isOptionsOpen' properties after files have been renamed. These are the properties that cause the comparision between the local copy of the project and that returned by the server to be different.

Don't rely on the lodash _.isEqual function, which results in false if properties `isEditingName` and `isOptionsOpen` are set to false, which is not relevant for comparing whether the files are the same.
Allow comparison of filtered properties if they are set to true.
@shinytang6
Copy link
Member

Hi @awarua , I took a quick look and I thought the problem lies in line 47 in project.controller.js. It seems that findByIdAndUpdate can't add new fields(here isEditingName and isOptionsOpen) into database. Maybe isEditingName and isOptionsOpen should be added to fileSchema or just remove these properties before we compare currentState.files withresponse.data.files ? Welcome discussion :)

@catarak
Copy link
Member

catarak commented Jun 18, 2018

thanks for your work on this, @shinytang6 and @awarua. i think a long term solution for this would be to separate certain parts of the file state into React and leave certain parts in Redux, or maybe follow @shinytang6's solution. when i started working on this project, i wasn't too familiar with react or redux, and didn't realize you didn't have to put the whole state into redux.

@jareddonovan
Copy link
Contributor Author

Thanks @catarak and @shinytang6. I'll have another go at this on the weekend. I'll probably take an attempt at @shinytang6's solution but will see if I can figure out enough about react/redux to implement what you describe too @catarak.

@catarak
Copy link
Member

catarak commented Jun 19, 2018

feel free to submit a WIP (work in progress) PR and ask questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants