LiveLocationSharingViewerViewModel: Handle new location sharing end behavior.

This commit is contained in:
SBiOSoftWhare
2022-07-28 09:26:40 +02:00
parent 65868d1570
commit 709ff95d2d
@@ -32,6 +32,10 @@ class LiveLocationSharingViewerViewModel: LiveLocationSharingViewerViewModelType
private var mapViewErrorAlertInfoBuilder: MapViewErrorAlertInfoBuilder
private var screenUpdateTimer: Timer?
// Last annotation that could be highlighted
// Used to set map position when location sharing is ended
private var lastHighlightableAnnotation: LocationAnnotation?
// MARK: Public
@@ -96,14 +100,6 @@ class LiveLocationSharingViewerViewModel: LiveLocationSharingViewerViewModelType
}
}
private func showNoUserLocationsAlert() {
let alertInfo: AlertInfo<LocationSharingAlertType> = AlertInfo(id: .userLocatingError, title: VectorL10n.locationSharingLiveNoUserLocationsErrorTitle, primaryButton:(VectorL10n.ok, { [weak self] in
self?.completion?(.done)
}))
state.bindings.alertInfo = alertInfo
}
private func processError(_ error: LocationSharingViewError) {
guard state.bindings.alertInfo == nil else {
return
@@ -189,23 +185,25 @@ class LiveLocationSharingViewerViewModel: LiveLocationSharingViewerViewModelType
let annotations: [UserLocationAnnotation] = self.userLocationAnnotations(from: usersLiveLocation)
var highlightedAnnotation: UserLocationAnnotation?
var highlightedAnnotation: LocationAnnotation?
if highlightFirstLocation {
highlightedAnnotation = self.getHighlightedAnnotation(from: annotations)
}
if let highlightableAnnotation = self.getHighlightedAnnotation(from: annotations) {
self.lastHighlightableAnnotation = highlightableAnnotation
}
if let lastHighlightableAnnotation = self.lastHighlightableAnnotation, usersLiveLocation.isEmpty {
highlightedAnnotation = InvisibleLocationAnnotation(coordinate: lastHighlightableAnnotation.coordinate)
}
let listViewItems = self.listItemsViewData(from: usersLiveLocation)
self.state.annotations = annotations
self.state.highlightedAnnotation = highlightedAnnotation
self.state.listItemsViewData = listViewItems
if usersLiveLocation.isEmpty {
// Advertize user that there is no locations
// Avoid to let the screen empty
self.showNoUserLocationsAlert()
}
}
private func highlighAnnotation(with userId: String) {