LocationSharingViewModel: Handle power level error display.

This commit is contained in:
SBiOSoftWhare
2022-07-26 10:56:37 +02:00
parent c8f32d24be
commit d5c4a25ab2
2 changed files with 32 additions and 7 deletions
@@ -101,10 +101,23 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
state.showLoadingIndicator = false
if let error = error {
state.bindings.alertInfo = AlertInfo(id: error,
title: VectorL10n.locationSharingPostFailureTitle,
message: VectorL10n.locationSharingPostFailureSubtitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.ok, nil))
let alertInfo: AlertInfo<LocationSharingAlertType>
switch error {
case .locationSharingPowerLevelError:
alertInfo = AlertInfo(id: error,
title: VectorL10n.locationSharingInvalidPowerLevelTitle,
message: VectorL10n.locationSharingInvalidPowerLevelMessage,
primaryButton: (VectorL10n.ok, nil))
default:
alertInfo = AlertInfo(id: error,
title: VectorL10n.locationSharingPostFailureTitle,
message: VectorL10n.locationSharingPostFailureSubtitle(AppInfo.current.displayName),
primaryButton: (VectorL10n.ok, nil))
}
state.bindings.alertInfo = alertInfo
}
}
@@ -174,9 +187,15 @@ class LocationSharingViewModel: LocationSharingViewModelType, LocationSharingVie
return
}
completion(.showLabFlagPromotionIfNeeded({ liveLocationEnabled in
if liveLocationEnabled {
completion(.checkLiveLocationCanBeStarted({ result in
switch result {
case .success:
self.checkLocationAuthorizationAndPresentTimerSelector()
case .failure(let error):
if case LiveLocationStartError.powerLevelNotHighEnough = error {
self.stopLoading(error: .locationSharingPowerLevelError)
}
}
}))
}