Skip to content

[chores] Stop JS logic in loci.js if map is not available#204

Merged
nemesifier merged 2 commits intomasterfrom
fix-js
Feb 26, 2026
Merged

[chores] Stop JS logic in loci.js if map is not available#204
nemesifier merged 2 commits intomasterfrom
fix-js

Conversation

@nemesifier
Copy link
Member

This prevents javascript errors if the JS is loaded on pages where the user doesn't have permission to see the map.

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • N/A I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • N/A I have updated the documentation.

This prevents javascript errors if the JS is loaded
on pages where the user doesn't have permission to see the map.
@nemesifier nemesifier self-assigned this Feb 26, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ffe032 and 3682a02.

📒 Files selected for processing (1)
  • django_loci/static/django-loci/js/loci.js
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0
🔇 Additional comments (1)
django_loci/static/django-loci/js/loci.js (1)

573-575: Good defensive guard for missing map context.

Line 573–575 correctly short-circuits geometryListeners() when getMap() is unavailable, preventing map-dependent calls from throwing on pages without map access.


📝 Walkthrough

Walkthrough

A guard clause is added to the geometryListeners function to exit early when the map is unavailable. This prevents subsequent operations that depend on the map object from executing when getMap() returns a falsy value. The remaining function logic is unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a guard to stop JS logic if the map is unavailable.
Description check ✅ Passed The description addresses the core issue and includes completed checklist items, but lacks issue reference and is somewhat brief.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-js

Comment @coderabbitai help to get the list of available commands and usage tips.

@nemesifier nemesifier merged commit 51b31bc into master Feb 26, 2026
20 checks passed
@nemesifier nemesifier deleted the fix-js branch February 26, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant