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

Sort MapSwitcher options #1088

Merged
merged 2 commits into from
May 23, 2022
Merged

Sort MapSwitcher options #1088

merged 2 commits into from
May 23, 2022

Conversation

vilbergs
Copy link
Contributor

Note: I did some minor refactoring that was out of scope, it's in a different commit in case it causes confusion

  • Make sure MapSwitcher maps are sorted
  • Refactor renderMenuItems to use Array.map

@@ -29,6 +29,11 @@ class MapSwitcher extends React.PureComponent {

handleLoading(maps) {
let { activeMap } = this.appModel.config;

maps.sort((a, b) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorting the array in place instead of copying, some people don't like that but in this case I think it's reasonable instead of copying what seem to be rather complex objects.

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'll approve this one, but would lika a review from @jesade-vbg or @jacobwod as well (since i haven't used the map-switcher-functionality lately).

The reasoning behind the need for another review is that i am unsure if mapConfigurationTitle could ever be undefined? (If it could we would go out with a bang when running the localeCompare).

There's no fallback in the backend when setting it as far as i can se.

image

@Hallbergs
Copy link
Member

Another thought: maybe the sorting of the maps should be done in the backend instead of in the client in the future... Seems like unnecessary load for the client.

@jacobwod jacobwod linked an issue May 23, 2022 that may be closed by this pull request
@jacobwod jacobwod self-requested a review May 23, 2022 07:45
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.

Nice job @vilbergs! 👍

@jacobwod jacobwod merged commit 564cc7c into hajkmap:develop May 23, 2022
@vilbergs
Copy link
Contributor Author

Thanks for the feedback @Hallbergs, here's my reasoning:

1. Potentially undefined titles

Good point. I took a quick look if there were any existing falsy checks for the title in the component, it didn't look like that so I went with the naive approach.

2. Sorting options in the backend

I tend to favour doing as much compute on the backend as possible, but client compute is also free compute, so I guess there's always a trade-off. With this being such a heavy application I think doing as much as possible on the backend seems reasonable.

@Hallbergs
Copy link
Member

Thanks for the feedback @Hallbergs, here's my reasoning:

1. Potentially undefined titles

Good point. I took a quick look if there were any existing falsy checks for the title in the component, it didn't look like that so I went with the naive approach.

2. Sorting options in the backend

I tend to favour doing as much compute on the backend as possible, but client compute is also free compute, so I guess there's always a trade-off. With this being such a heavy application I think doing as much as possible on the backend seems reasonable.

The fact that you reasoned about it is good enough for me! Good job :) Always fun to see a new contributer, welcome!

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.

MapSwitcher: sort by label, not file name
3 participants