[openstreetmap/openstreetmap-website] Simplify iD's initialisation (PR #5597)
Holger Jeromin
notifications at github.com
Tue Feb 4 08:57:48 UTC 2025
@HolgerJeromin commented on this pull request.
> -
- if (mapParams.object) {
- params.set("id", mapParams.object.type + "/" + mapParams.object.id);
- mapParams = OSM.parseHash(location.hash);
- if (mapParams.center) {
- params.set("map", mapParams.zoom + "/" + mapParams.center.lat + "/" + mapParams.center.lng);
- }
- } else if (id.data("lat") && id.data("lon")) {
- params.set("map", "16/" + id.data("lat") + "/" + id.data("lon"));
- } else {
- params.set("map", (mapParams.zoom || 17) + "/" + mapParams.lat + "/" + mapParams.lon);
- }
+ if (id.data("configured") === false) {
+ alert(I18n.t("site.edit.id_not_configured"));
+ return;
+ }
Early return results often in less indention which is IMO good.
And while reading the code you do not need to find the `else` branch.
Having the branch with fewer code lines on top can help without the downsides of multiple returns.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5597#discussion_r1940756914
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5597/review/2592145689 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250204/154fe206/attachment.htm>
More information about the rails-dev
mailing list