-
Notifications
You must be signed in to change notification settings - Fork 45
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
Feature/1267 refactor bookmarks plugin #1270
Conversation
Refactor from class component to functional component.
Refactor from class component to functional component.
Refactor from class component to functional component.
Remove setMap and setApp as the map and app state are not meant to be updated.
Fix a bug with state handling and remove an unused `useEffect` import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just given it a quick look. Will give it a deeper dive next week. However, i have some questions right away:
- Why are you rewriting and incorporating react functionality into
BookmarksModel.js
? This was just a regular js class, not a react class component (should/does not have to not be rewritten). Also i really don't think it a good idea with a react component(?) returning an object...? Or is this some kind of custom hook with bad naming? (Custom hooks should have theuse
keyword in front). I might just be too tired and missing something obvious. My main issue with this is that all our plugins are written with components along with one (or more) "model" (a regular js class). I don't see the point diverging from this "standard". - You "initialize" the model by writing
const bookmarksModel = BookmarksModel({ app, map });
. This code will run on every re-render ofBookmarks.js
which is really unnecessary. You can look at the dummy-example where i thoroughly explain how this should be done. updateCustomProp
is unused and should be removed.
I agree with Hallbergs comment. BookmarkModel.js should be kept as ordinary class, no reason to bloat it with react. I will look again and test when this is fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with other reviewers. I think there's a clear example in the Dummy plugin. Otherwise check in e.g. Sketch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if you're done? I checked the code again, and found some issues.
First of all, make sure we're compiling without warnings. See image below:
The warnings stems from the fact that you've added stuff (from Dummy
?) that are unnecessary, For example the pluginShown
state was added in Dummy
to show how to handle events from closing and opening the plugin window.
It also seems like you are adding a localObserver
without actually using it. Not sure why.
Create file containing all necessary constant values for the Bookmarks plugin.
Reduced Local storage values to only include `settings`. Removed unused values `name`, `sortOrder`, and `favorite`.
Remove unused states, functions and `React.useEffect` hook from code.
Implement support for legacy bookmarks using `LocalStorageHelper` for backward compatibility.
Update code to handle and render new object structure with updated properties.
Add every legacy bookmark to corresponding map-specific storage using the `m` parameter.
Pull request approved, ready for merge.
Closes #1267.