Skip to content

Conversation

hikerpig
Copy link
Contributor

Description

Edit a note and unlink its folder or storage, current implementation of browser/main/Detail/MarkdownNoteDetail.js will throw exception due to invalid object property access, this PR add a safe guard to prevent it.

Issue fixed

Type of changes

  • 🔘 Bug fix (Change that fixed an issue)
  • ⚪ Breaking change (Change that can cause existing functionality to change)
  • ⚪ Improvement (Change that improves the code. Maybe performance or development improvement)
  • ⚪ Feature (Change that adds new functionality)
  • ⚪ Documentation change (Change that modifies documentation. Maybe typo fixes)

Checklist:

  • 🔘 My code follows the project code style
  • ⚪ I have written test for my code and it has been tested
  • 🔘 All existing tests have been passed
  • ⚪ I have attached a screenshot/video to visualize my change if possible

@ZeroX-DG ZeroX-DG added needs extra review 🔎 Pull request requires review from an additional reviewer. awaiting review ❇️ Pull request is awaiting a review. and removed needs extra review 🔎 Pull request requires review from an additional reviewer. labels Jul 26, 2019
@ZeroX-DG
Copy link
Member

@hikerpig can you resolve the conflict please?

@hikerpig
Copy link
Contributor Author

@ZeroX-DG Done 🎉

@ZeroX-DG
Copy link
Member

@hikerpig thank you for resolving the conflict. It seem the bug is still there, I haven't have the time to look into it yet, if you can investigate this bug before me please do:)
image

@hikerpig
Copy link
Contributor Author

@ZeroX-DG I see many features are deployed after my initial commit. All this errors occur when no storage matches the storageKey, some of them are purposely thrown by this findStorage method.

I just added some guards to avoid some scenarios, currently my editor won't break after storage is unlinked.

But I see there are still some places called findStorage without a try/catch guard, maybe a thorough mine-sweeping is needed?

@ZeroX-DG
Copy link
Member

@hikerpig yes, I check out some places that call findStorage and I think it's not very safe to not catch the error at all. But catching the error is a difficult work, you have to choose to ignore an action or show a dialog to the user so if you want we can separate it into another PR.

@hikerpig
Copy link
Contributor Author

That will be great. This PR should be done by now.

And I think instead of throwing an error in findStorage, it should just return null if no matches found, and all callers should keep in mind and handle the null result, a simple if (storage) test would be better than try/catch. How do you feel about this @ZeroX-DG ?

If that's ok, I will take a look in this and open a draft PR in one or two days.

@ZeroX-DG
Copy link
Member

@hikerpig that's actually a good suggestion since findStorage only throw 1 error, we can reduce that to return null instead. BTW, I think the bug is not quite fixed yet, after you perform all the steps to reproduce the bug, everything works ok untill you click on the tag list button on side bar or when you add and unlink the storage another time. The new bug is caused by this function:

https://github.com/BoostIO/Boostnote/blob/5f56d3e0de48e3c49b454558caac5c81ea4430cf/browser/main/NoteList/index.js#L1108

I think it's caused by inconsistent between note list and storage list since the storage has been removed but the note list still try to access it. Can you investigate and fix it also? Thank you 👍

@ZeroX-DG ZeroX-DG added awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. and removed awaiting review ❇️ Pull request is awaiting a review. labels Mar 29, 2020
@hikerpig
Copy link
Contributor Author

@ZeroX-DG I've fixed the errors in NodeList/index.js, have a look ~

Copy link
Member

@ZeroX-DG ZeroX-DG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool. LGTM 🎉

@ZeroX-DG ZeroX-DG added approved 👍 Pull request has been approved by sufficient reviewers. and removed awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. labels Mar 31, 2020
@Rokt33r Rokt33r added this to the v0.15.3 milestone Apr 6, 2020
@Rokt33r Rokt33r merged commit 6ee9258 into BoostIO:master Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved 👍 Pull request has been approved by sufficient reviewers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants