Skip to content
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

Merged
merged 19 commits into from
Feb 3, 2023

Conversation

linusfj
Copy link
Member

@linusfj linusfj commented Jan 20, 2023

Closes #1267.

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.
@jesade-vbg
Copy link
Contributor

Nice! It looks promising. I will check more and test next week. Had a quick check regarding storage format and it's indeed the parameters that are stored, including map name. Bookmarks are per domain not per map.

image

Copy link
Member

@Hallbergs Hallbergs left a 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 the use 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 of Bookmarks.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.

@jesade-vbg
Copy link
Contributor

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.

Copy link
Member

@jacobwod jacobwod left a 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.

Copy link
Member

@Hallbergs Hallbergs left a 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:
image

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.
linusfj and others added 2 commits January 31, 2023 11:10
Add every legacy bookmark to corresponding map-specific storage using the `m` parameter.
@linusfj linusfj dismissed jacobwod’s stale review February 3, 2023 11:18

Pull request approved, ready for merge.

@linusfj linusfj merged commit 01feb29 into develop Feb 3, 2023
@linusfj linusfj deleted the feature/1267-refactor-bookmarks-plugin branch February 3, 2023 11:18
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.

4 participants