mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[ios] Fix track recording points updates subscribe/unsubscribe
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
committed by
Yannik Bloscheck
parent
266d62831f
commit
e0c579634b
@@ -1,5 +1,6 @@
|
||||
protocol PlacePageInteractorProtocol: AnyObject {
|
||||
func viewWillAppear()
|
||||
func viewWillDisappear()
|
||||
func updateTopBound(_ bound: CGFloat, duration: TimeInterval)
|
||||
}
|
||||
|
||||
@@ -19,12 +20,11 @@ class PlacePageInteractor: NSObject {
|
||||
self.mapViewController = mapViewController
|
||||
super.init()
|
||||
addToBookmarksManagerObserverList()
|
||||
subscribeOnTrackActivePointUpdates()
|
||||
subscribeOnTrackActivePointUpdatesIfNeeded()
|
||||
}
|
||||
|
||||
deinit {
|
||||
removeFromBookmarksManagerObserverList()
|
||||
unsubscribeFromTrackActivePointUpdates()
|
||||
}
|
||||
|
||||
private func updatePlacePageIfNeeded() {
|
||||
@@ -53,7 +53,8 @@ class PlacePageInteractor: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
private func subscribeOnTrackActivePointUpdates() {
|
||||
private func subscribeOnTrackActivePointUpdatesIfNeeded() {
|
||||
unsubscribeFromTrackActivePointUpdates()
|
||||
guard placePageData.objectType == .track, let trackData = placePageData.trackData else { return }
|
||||
bookmarksManager.setElevationActivePointChanged(trackData.trackId) { [weak self] distance in
|
||||
self?.trackActivePointPresenter?.updateActivePointDistance(distance)
|
||||
@@ -65,7 +66,6 @@ class PlacePageInteractor: NSObject {
|
||||
}
|
||||
|
||||
private func unsubscribeFromTrackActivePointUpdates() {
|
||||
guard placePageData.trackData?.onActivePointChangedHandler != nil else { return }
|
||||
bookmarksManager.resetElevationActivePointChanged()
|
||||
bookmarksManager.resetElevationMyPositionChanged()
|
||||
}
|
||||
@@ -89,6 +89,10 @@ extension PlacePageInteractor: PlacePageInteractorProtocol {
|
||||
updatePlacePageIfNeeded()
|
||||
}
|
||||
|
||||
func viewWillDisappear() {
|
||||
unsubscribeFromTrackActivePointUpdates()
|
||||
}
|
||||
|
||||
func updateTopBound(_ bound: CGFloat, duration: TimeInterval) {
|
||||
mapViewController?.setPlacePageTopBound(bound, duration: duration)
|
||||
}
|
||||
|
||||
@@ -79,6 +79,11 @@ final class PlacePageScrollView: UIScrollView {
|
||||
updatePreviewOffset()
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
interactor?.viewWillDisappear()
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
super.traitCollectionDidChange(previousTraitCollection)
|
||||
// Update layout when the device was rotated but skip when the appearance was changed.
|
||||
|
||||
Reference in New Issue
Block a user