Skip to content

[Code health] Don't allow saving a duplicate vertex during polygon drawing session#3750

Open
shobhitagarwal1612 wants to merge 7 commits into
masterfrom
polygon-refactor-latest
Open

[Code health] Don't allow saving a duplicate vertex during polygon drawing session#3750
shobhitagarwal1612 wants to merge 7 commits into
masterfrom
polygon-refactor-latest

Conversation

@shobhitagarwal1612
Copy link
Copy Markdown
Member

Towards #3679

Separate committed and tentative vertices in PolygonDrawingSession. This allows the persistence layer to safely store only the committed vertices without having to assume that the last vertex is user committed vertex or not.

Changes verified using unit tests and testing the flow on a physical device.

@andreia-ferreira PTAL?

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 91.42857% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.09%. Comparing base (6fa95fb) to head (ffb8a30).

Files with missing lines Patch % Lines
...lection/tasks/polygon/PolygonDrawingSessionImpl.kt 88.46% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3750      +/-   ##
============================================
+ Coverage     68.06%   68.09%   +0.03%     
- Complexity     1613     1615       +2     
============================================
  Files           368      368              
  Lines          9528     9538      +10     
  Branches       1242     1244       +2     
============================================
+ Hits           6485     6495      +10     
  Misses         2376     2376              
  Partials        667      667              
Files with missing lines Coverage Δ
...acollection/tasks/polygon/DrawAreaTaskViewModel.kt 82.43% <100.00%> (+0.11%) ⬆️
...acollection/tasks/polygon/PolygonDrawingSession.kt 100.00% <ø> (ø)
...lection/tasks/polygon/PolygonDrawingSessionImpl.kt 92.98% <88.46%> (-0.77%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

_vertices = updatedVertices.toImmutableList()
}
override val hasSelfIntersection: Boolean
get() = isSelfIntersecting(displayVertices)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I can't seem to close the polygons. When debugging i noticed that isSelfIntersecting now returns true when getting the state of the complete button. It could be because now this method checks displayVertices which includes the tentativeVertex, and that is equal to the first vertex

Screen_recording_20260521_143226.webm

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm unable to reproduce this on my device. Are you able to consistently reproduce it or is it flaky?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it's consistently reproducible. But I've found out it's because I was clicking twice to drop the first point because clicking the first time doesn't make the white circle marker to show up until the camera is dragged. So I believe the problem is that dropping two points in the starting vertex is allowed, but then leads to an invalid polygon

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.

2 participants