[ios] Fix track recording points updates subscribe/unsubscribe

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
Kiryl Kaveryn
2025-08-19 14:37:08 +04:00
committed by Yannik Bloscheck
parent 266d62831f
commit e0c579634b
2 changed files with 13 additions and 4 deletions

View File

@@ -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)
} }

View File

@@ -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.