mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03: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 {
|
protocol PlacePageInteractorProtocol: AnyObject {
|
||||||
func viewWillAppear()
|
func viewWillAppear()
|
||||||
|
func viewWillDisappear()
|
||||||
func updateTopBound(_ bound: CGFloat, duration: TimeInterval)
|
func updateTopBound(_ bound: CGFloat, duration: TimeInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,12 +20,11 @@ class PlacePageInteractor: NSObject {
|
|||||||
self.mapViewController = mapViewController
|
self.mapViewController = mapViewController
|
||||||
super.init()
|
super.init()
|
||||||
addToBookmarksManagerObserverList()
|
addToBookmarksManagerObserverList()
|
||||||
subscribeOnTrackActivePointUpdates()
|
subscribeOnTrackActivePointUpdatesIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
removeFromBookmarksManagerObserverList()
|
removeFromBookmarksManagerObserverList()
|
||||||
unsubscribeFromTrackActivePointUpdates()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updatePlacePageIfNeeded() {
|
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 }
|
guard placePageData.objectType == .track, let trackData = placePageData.trackData else { return }
|
||||||
bookmarksManager.setElevationActivePointChanged(trackData.trackId) { [weak self] distance in
|
bookmarksManager.setElevationActivePointChanged(trackData.trackId) { [weak self] distance in
|
||||||
self?.trackActivePointPresenter?.updateActivePointDistance(distance)
|
self?.trackActivePointPresenter?.updateActivePointDistance(distance)
|
||||||
@@ -65,7 +66,6 @@ class PlacePageInteractor: NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func unsubscribeFromTrackActivePointUpdates() {
|
private func unsubscribeFromTrackActivePointUpdates() {
|
||||||
guard placePageData.trackData?.onActivePointChangedHandler != nil else { return }
|
|
||||||
bookmarksManager.resetElevationActivePointChanged()
|
bookmarksManager.resetElevationActivePointChanged()
|
||||||
bookmarksManager.resetElevationMyPositionChanged()
|
bookmarksManager.resetElevationMyPositionChanged()
|
||||||
}
|
}
|
||||||
@@ -89,6 +89,10 @@ extension PlacePageInteractor: PlacePageInteractorProtocol {
|
|||||||
updatePlacePageIfNeeded()
|
updatePlacePageIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func viewWillDisappear() {
|
||||||
|
unsubscribeFromTrackActivePointUpdates()
|
||||||
|
}
|
||||||
|
|
||||||
func updateTopBound(_ bound: CGFloat, duration: TimeInterval) {
|
func updateTopBound(_ bound: CGFloat, duration: TimeInterval) {
|
||||||
mapViewController?.setPlacePageTopBound(bound, duration: duration)
|
mapViewController?.setPlacePageTopBound(bound, duration: duration)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ final class PlacePageScrollView: UIScrollView {
|
|||||||
updatePreviewOffset()
|
updatePreviewOffset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewWillDisappear(_ animated: Bool) {
|
||||||
|
super.viewWillDisappear(animated)
|
||||||
|
interactor?.viewWillDisappear()
|
||||||
|
}
|
||||||
|
|
||||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
super.traitCollectionDidChange(previousTraitCollection)
|
super.traitCollectionDidChange(previousTraitCollection)
|
||||||
// Update layout when the device was rotated but skip when the appearance was changed.
|
// Update layout when the device was rotated but skip when the appearance was changed.
|
||||||
|
|||||||
Reference in New Issue
Block a user