Skip to content

Commit

Permalink
Try fix "The firmware update button is constantly active until the ap…
Browse files Browse the repository at this point in the history
…plication is restarted" (#716)

**Background**

Right now we have problem with infinite update button active

**Changes**

- Reinvalidate update button when connection state changed

**Test plan**

Try update flipper
  • Loading branch information
LionZXY authored Oct 10, 2023
1 parent f9800cd commit f389fb9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- [FIX] Openning animation
- [FIX] Swipe refresh modifier use in root level
- [FIX] Fix overflow in key small
- [FIX] Try fix "The firmware update button is constantly active until the application is restarted"

# 1.6.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.flipperdevices.updater.card.helpers.delegates.UpdateOfferDelegate
import com.squareup.anvil.annotations.ContributesBinding
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flatMapLatest
import javax.inject.Inject

interface UpdateOfferProviderApi {
Expand All @@ -18,10 +19,12 @@ class UpdateOfferProvider @Inject constructor(
) : UpdateOfferProviderApi {

override fun isUpdateRequire(serviceApi: FlipperServiceApi): Flow<Boolean> {
return combine(
delegates.map { it.isRequire(serviceApi) }
) { delegate ->
return@combine delegate.any { it }
return serviceApi.connectionInformationApi.getConnectionStateFlow().flatMapLatest {
combine(
delegates.map { it.isRequire(serviceApi) }
) { delegate ->
return@combine delegate.any { it }
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.flipperdevices.updater.card.helpers

import com.flipperdevices.bridge.api.manager.delegates.FlipperConnectionInformationApi
import com.flipperdevices.bridge.api.manager.ktx.state.ConnectionState
import com.flipperdevices.bridge.api.manager.ktx.state.FlipperSupportedState
import com.flipperdevices.bridge.service.api.FlipperServiceApi
import com.flipperdevices.updater.card.helpers.delegates.UpdateOfferDebugFlagAlways
import com.flipperdevices.updater.card.helpers.delegates.UpdateOfferFlipperManifest
Expand Down Expand Up @@ -34,6 +37,11 @@ class UpdateOfferProviderTest {
every { delegateFlagAlways.isRequire(serviceApi) } returns flowOf(false)
every { delegateManifest.isRequire(serviceApi) } returns flowOf(false)
every { delegateRegionFile.isRequire(serviceApi) } returns flowOf(false)
val connectionInformationApi: FlipperConnectionInformationApi = mockk {
every { getConnectionStateFlow() } returns
flowOf(ConnectionState.Ready(supportedState = FlipperSupportedState.READY))
}
every { serviceApi.connectionInformationApi } returns connectionInformationApi
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class UpdaterApiImpl @Inject constructor(
) : UpdaterApi, LogTagProvider {
override val TAG = "UpdaterApi"

private val updatingState = MutableStateFlow<UpdatingStateWithRequest>(
private val updatingState = MutableStateFlow(
UpdatingStateWithRequest(UpdatingState.NotStarted, request = null)
)

Expand Down

0 comments on commit f389fb9

Please sign in to comment.