-
Notifications
You must be signed in to change notification settings - Fork 148
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
Fix view annotation losing its feature association after update #1446
Fix view annotation losing its feature association after update #1446
Conversation
@@ -193,7 +193,7 @@ public final class ViewAnnotationManager { | |||
let isHidden = !(options.visible ?? true) | |||
expectedHiddenByView[view] = isHidden | |||
viewsById[id]?.isHidden = isHidden | |||
if let id = currentFeatureId, id != options.associatedFeatureId { | |||
if let id = currentFeatureId, let updatedId = options.associatedFeatureId, id != updatedId { | |||
viewsByFeatureIds[id] = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not quite understand this change. It looks like the same lines to me. Can you explain to me, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, now I see – options.associatedFeatureId
has to be non-nil, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By unwrapping the options.associatedFeatureId
this makes sure that a view loses its feature id association only when the feature id got updated, previously it would loose the association on every update.
Some sample code to illustrate this:
let view = UIView()
let id = UUID().uuidString
let options = ViewAnnotationOptions(associatedFeatureId: id)
try manager.add(view, options: options)
try manager.update(view, options: ViewAnnotationOptions(width: 100, height: 100))
// previosly
manager.view(forFeatureId: id) // nil 💥
// fixed
manager.view(forFeatureId: id) // returns the view ✅
@@ -193,7 +193,7 @@ public final class ViewAnnotationManager { | |||
let isHidden = !(options.visible ?? true) | |||
expectedHiddenByView[view] = isHidden | |||
viewsById[id]?.isHidden = isHidden | |||
if let id = currentFeatureId, id != options.associatedFeatureId { | |||
if let id = currentFeatureId, let updatedId = options.associatedFeatureId, id != updatedId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
if let id = currentFeatureId, let updatedId = options.associatedFeatureId, id != updatedId { | |
if !(currentFeatureId == options.associatedFeatureId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also probably make sense to add an explicit comment above
3ea5e15
to
a29ca8b
Compare
* Update changelog (#1418) * Add style toggle to location example (#1413) * [XCParty] Add tag name if HEAD has any (#1424) * [XCParty] Export crash reports for XCResult (#1434) * Expose a way to initialise TilesetDescriptorOptionsForTilesets (#1431) * Add cast shadow option to 3d puck config (#1435) * Mark camera functions as unsupported for globe projection, invocation results in a no-op (#1440) * Rotation gesture threshold and simultaneousRotateAndPinchToZoomEnabled option (#1429) * Add option to support measurements from the only last run (#1445) * Update examples (#1443) * Fix flaky test (#1450) * Fix view annotation losing its feature association after update (#1446) * Enable `modelCastsShadow` option for custom location puck config (#1447) * enabled model casts shadows option for custom location puck configuration * Provide default value for list of last-run metrics (#1453) * Update CoreMaps to `10.7.0-rc.1` (#1456) * Update CoreMaps to 10.7.0-rc.1 * Update changelog * Update changelog header (#1459) * Update 10.7.0 versions (#1460) Co-authored-by: ZiZi <44972592+ZiZasaurus@users.noreply.github.com> Co-authored-by: Roman Laitarenko <roman.laitarenko@mapbox.com> Co-authored-by: Tobrun <tobrun.van.nuland@gmail.com>
* Add style toggle to location example (#1413) * [XCParty] Add tag name if HEAD has any (#1424) * [XCParty] Export crash reports for XCResult (#1434) * Expose a way to initialise TilesetDescriptorOptionsForTilesets (#1431) * Add cast shadow option to 3d puck config (#1435) * Mark camera functions as unsupported for globe projection, invocation results in a no-op (#1440) * Rotation gesture threshold and simultaneousRotateAndPinchToZoomEnabled option (#1429) * Add option to support measurements from the only last run (#1445) * Update examples (#1443) * Fix flaky test (#1450) * Fix view annotation losing its feature association after update (#1446) * Enable `modelCastsShadow` option for custom location puck config (#1447) * enabled model casts shadows option for custom location puck configuration * Provide default value for list of last-run metrics (#1453) * Update CoreMaps to `10.7.0-rc.1` (#1456) * Update CoreMaps to 10.7.0-rc.1 * Update changelog * Update changelog header (#1459) * Update 10.7.0 versions (#1460) Co-authored-by: ZiZi <44972592+ZiZasaurus@users.noreply.github.com> Co-authored-by: Roman Laitarenko <roman.laitarenko@mapbox.com> Co-authored-by: Tobrun <tobrun.van.nuland@gmail.com>
* Remove unnecessary check before updating a geo json source * Update changelog
* Remove unnecessary check before updating a geo json source * Update changelog
* Remove unnecessary check before updating a geo json source * Update changelog
This PR addresses the issue when a view annotation loses its feature id association when updating other(non-
associatedFeatureId
) properties.Pull request checklist:
## main
heading near the top).