diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-02-04 02:31:03 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-02-04 02:31:03 -0600 |
commit | c5e289dc4111fd23fbab4b4695d405b8fccea349 (patch) | |
tree | 1faa6228623d39eb8fdd1d4da0852741ec111519 | |
parent | dac657032851dbd6b13be72253e4f8777c67b439 (diff) | |
download | etbsa-trackermap-mobile-c5e289dc4111fd23fbab4b4695d405b8fccea349.tar.gz etbsa-trackermap-mobile-c5e289dc4111fd23fbab4b4695d405b8fccea349.tar.bz2 etbsa-trackermap-mobile-c5e289dc4111fd23fbab4b4695d405b8fccea349.zip |
Only refresh map markers when some of them changes
-rw-r--r-- | iosApp/iosApp/Map/MapView.swift | 12 | ||||
-rw-r--r-- | shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/iosApp/iosApp/Map/MapView.swift b/iosApp/iosApp/Map/MapView.swift index 989f17a..2c86c3b 100644 --- a/iosApp/iosApp/Map/MapView.swift +++ b/iosApp/iosApp/Map/MapView.swift @@ -28,8 +28,11 @@ struct MapView: UIViewControllerRepresentable { @Binding var selected: Marker? var markerCallback: MarkerCallback? + var shouldCenter = true + class Coordinator { var shouldCenter: Bool = true + var oldMarkers: [Marker] = [] } func makeCoordinator() -> Coordinator { @@ -48,10 +51,13 @@ struct MapView: UIViewControllerRepresentable { uiViewController.setMapLayer(layer) // MARK: - Set markers - uiViewController.display(markers: markers, - isReport: false, - center: context.coordinator.shouldCenter) + if context.coordinator.oldMarkers != markers { + uiViewController.display(markers: markers, + isReport: false, + center: context.coordinator.shouldCenter) + } context.coordinator.shouldCenter = false + context.coordinator.oldMarkers = markers // MARK: - Center selected marker if let selected = selected { diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt index 78bcf3b..e9865e8 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt @@ -59,7 +59,7 @@ open class ApiClient( } install(Logging) { logger = Logger.DEFAULT - level = LogLevel.ALL + level = LogLevel.INFO } } |