mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-22 00:42:38 +00:00
fix incorrect state when actions are not taken at launch
This commit is contained in:
1 file changed
+15
-2
@@ -82,7 +82,20 @@ class LaunchViewModel(private val application: Application): ViewModel() {
|
||||
data object Ready : LaunchUIState()
|
||||
}
|
||||
|
||||
private val _uiState = MutableStateFlow<LaunchUIState>(LaunchUIState.Initial)
|
||||
private val _uiState: MutableStateFlow<LaunchUIState>
|
||||
|
||||
init {
|
||||
val preferenceUtils = PreferenceUtils.get(application)
|
||||
val initialCancel = !preferenceUtils.getBoolean(PreferenceUtils.Key.UPDATE_AUTOMATICALLY)
|
||||
&& !preferenceUtils.getBoolean(PreferenceUtils.Key.LOAD_AUTOMATICALLY)
|
||||
|
||||
// fixes a single frame of progress being displayed when we're not actually going to do work
|
||||
_uiState = MutableStateFlow<LaunchUIState>(
|
||||
if (initialCancel) LaunchUIState.Cancelled(LaunchCancelReason.AUTOMATIC)
|
||||
else LaunchUIState.Initial
|
||||
)
|
||||
}
|
||||
|
||||
val uiState = _uiState.asStateFlow()
|
||||
|
||||
val nextLauncherUpdate = ReleaseManager.get(application).availableLauncherUpdate
|
||||
@@ -210,10 +223,10 @@ class LaunchViewModel(private val application: Application): ViewModel() {
|
||||
val reason = if (isAutomatic) LaunchCancelReason.AUTOMATIC else LaunchCancelReason.MANUAL
|
||||
|
||||
isCancelling = true
|
||||
_uiState.emit(LaunchUIState.Cancelled(reason, true))
|
||||
|
||||
val releaseManager = ReleaseManager.get(application)
|
||||
if (releaseManager.isInUpdate) {
|
||||
_uiState.emit(LaunchUIState.Cancelled(reason, true))
|
||||
releaseManager.cancelUpdate()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user