Skip to content

Commit 64877e3

Browse files
committed
fixed duplicate annotations issue on answering multi quest anser
- updated version no to 1.0(36) to 1.0(37) - fixed duplicate annotations getting added on multi quest ans
1 parent 7052581 commit 64877e3

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

GoInfoGame/GoInfoGame.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,7 +2674,7 @@
26742674
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
26752675
CODE_SIGN_IDENTITY = "Apple Development";
26762676
CODE_SIGN_STYLE = Automatic;
2677-
CURRENT_PROJECT_VERSION = 36;
2677+
CURRENT_PROJECT_VERSION = 37;
26782678
DEVELOPMENT_TEAM = G8MQVE5WWW;
26792679
GENERATE_INFOPLIST_FILE = YES;
26802680
INFOPLIST_FILE = GoInfoGame/Info.plist;
@@ -2712,7 +2712,7 @@
27122712
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
27132713
CODE_SIGN_IDENTITY = "Apple Development";
27142714
CODE_SIGN_STYLE = Automatic;
2715-
CURRENT_PROJECT_VERSION = 36;
2715+
CURRENT_PROJECT_VERSION = 37;
27162716
DEVELOPMENT_TEAM = G8MQVE5WWW;
27172717
GENERATE_INFOPLIST_FILE = YES;
27182718
INFOPLIST_FILE = GoInfoGame/Info.plist;

GoInfoGame/GoInfoGame/UI/Map/CustomMap.swift

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,24 @@ struct CustomMap: UIViewRepresentable {
7878
// Updates the UIView with new data
7979
func updateUIView(_ mapView: MKMapView, context: Context) {
8080
// mapView.setCenter(userLocation, animated: true)
81-
if isMultiSelectModeEnabled,
82-
selectedAnnotations.isEmpty {
83-
Task { await manageAnnotations(mapView, context: context) }
84-
}
85-
context.coordinator.updateUserRegion(mapView)
86-
context.coordinator.updateVisibleAnnotations(in: mapView)
87-
if context.coordinator.previousAnnotations != items {
88-
context.coordinator.previousAnnotations = items
89-
Task {
90-
await manageAnnotations(mapView, context: context)
81+
Task {
82+
83+
if context.coordinator.previosMultiSelectionMode != isMultiSelectModeEnabled {
84+
context.coordinator.previosMultiSelectionMode = isMultiSelectModeEnabled
85+
/*Task {*/ await manageAnnotations(mapView, context: context) /*}*/
86+
}
87+
context.coordinator.updateUserRegion(mapView)
88+
context.coordinator.updateVisibleAnnotations(in: mapView)
89+
if context.coordinator.previousAnnotations != items {
90+
context.coordinator.previousAnnotations = items
91+
// Task {
92+
await manageAnnotations(mapView, context: context)
93+
// }
9194
}
9295
}
9396

9497

98+
9599
// Remove existing overlays
96100
mapView.overlays.forEach { mapView.removeOverlay($0) }
97101

@@ -153,6 +157,7 @@ struct CustomMap: UIViewRepresentable {
153157
private var zoomReachedLimit: Bool = false
154158

155159
var previousAnnotations: [DisplayUnitWithCoordinate] = []
160+
var previosMultiSelectionMode: Bool = false
156161
private var annotations: [DisplayUnitAnnotation] = []
157162
private(set) var clusterManager: ClusterManager = ClusterManager<DisplayUnitAnnotation>(configuration: .init(maxZoomLevel: 17, minCountForClustering: 2, clusterPosition: .nearCenter))
158163

@@ -529,9 +534,9 @@ struct CustomMap: UIViewRepresentable {
529534

530535
await context.coordinator.clusterManager.removeAll()
531536
await context.coordinator.reloadMap()
532-
let existingCoordinates = mapView.annotations.compactMap {
533-
($0 as? DisplayUnitAnnotation)?.coordinate
534-
}
537+
// let existingCoordinates = mapView.annotations.compactMap {
538+
// ($0 as? DisplayUnitAnnotation)?.coordinate
539+
// }
535540

536541
// Check for modals or settings before changing map
537542
if isPresented {

GoInfoGame/GoInfoGame/UI/Map/MapView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ struct MapView: View {
171171
onCancel: {
172172
viewModel.selectedAnnotaions.removeAll()
173173
viewModel.selectedAnnotationType = nil
174-
DispatchQueue.main.async {
175-
viewModel.isMultiSelectModeEnabled = false
176-
viewModel.selectedAnnotaions = Set<DisplayUnitAnnotation>()
177-
}
174+
// DispatchQueue.main.async {
175+
viewModel.isMultiSelectModeEnabled = false
176+
viewModel.selectedAnnotaions = Set<DisplayUnitAnnotation>()
177+
// }
178178
},
179179
onAnswerQuests: {
180180
isPresented = true

GoInfoGame/GoInfoGame/UI/Map/MapViewModel.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ class MapViewModel: ObservableObject {
7272
}
7373
self.selectedAnnotaions.removeAll()
7474
self.selectedAnnotationType = nil
75-
DispatchQueue.main.async {
76-
self.isMultiSelectModeEnabled = false
77-
self.selectedAnnotaions = Set<DisplayUnitAnnotation>()
78-
}
75+
self.isMultiSelectModeEnabled = false
76+
self.selectedAnnotaions = Set<DisplayUnitAnnotation>()
7977
}
8078
}
8179
return displayUnit

0 commit comments

Comments
 (0)