Skip to content

Commit

Permalink
fix: update api version on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed Dec 3, 2024
1 parent 7a6c3c6 commit ceabecb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import com.wire.kalium.logic.feature.conversation.CheckConversationInviteCodeUse
import com.wire.kalium.logic.feature.debug.SynchronizeExternalDataResult
import com.wire.kalium.logic.feature.server.GetServerConfigResult
import com.wire.kalium.logic.feature.server.GetServerConfigUseCase
import com.wire.kalium.logic.feature.server.UpdateApiVersionsUseCase
import com.wire.kalium.logic.feature.session.CurrentSessionFlowUseCase
import com.wire.kalium.logic.feature.session.CurrentSessionResult
import com.wire.kalium.logic.feature.session.DoesValidSessionExistResult
Expand Down Expand Up @@ -122,7 +123,8 @@ class WireActivityViewModel @Inject constructor(
private val observeScreenshotCensoringConfigUseCaseProviderFactory: ObserveScreenshotCensoringConfigUseCaseProvider.Factory,
private val globalDataStore: Lazy<GlobalDataStore>,
private val observeIfE2EIRequiredDuringLoginUseCaseProviderFactory: ObserveIfE2EIRequiredDuringLoginUseCaseProvider.Factory,
private val workManager: Lazy<WorkManager>
private val workManager: Lazy<WorkManager>,
private val updateApiVersions: UpdateApiVersionsUseCase
) : ViewModel() {

var globalAppState: GlobalAppState by mutableStateOf(GlobalAppState())
Expand Down Expand Up @@ -157,6 +159,13 @@ class WireActivityViewModel @Inject constructor(
observeScreenshotCensoringConfigState()
observeAppThemeState()
observeLogoutState()
updateApiVersionsOnStart()
}

private fun updateApiVersionsOnStart() {
viewModelScope.launch {
updateApiVersions()
}
}

@Suppress("TooGenericExceptionCaught")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import com.wire.kalium.logic.feature.client.ObserveNewClientsUseCase
import com.wire.kalium.logic.feature.conversation.CheckConversationInviteCodeUseCase
import com.wire.kalium.logic.feature.server.GetServerConfigResult
import com.wire.kalium.logic.feature.server.GetServerConfigUseCase
import com.wire.kalium.logic.feature.server.UpdateApiVersionsUseCase
import com.wire.kalium.logic.feature.session.CurrentSessionFlowUseCase
import com.wire.kalium.logic.feature.session.CurrentSessionResult
import com.wire.kalium.logic.feature.session.DoesValidSessionExistResult
Expand Down Expand Up @@ -682,6 +683,7 @@ class WireActivityViewModelTest {
flowOf(false)
every { workManager.cancelAllWorkByTag(any()) } returns OperationImpl()
every { workManager.enqueueUniquePeriodicWork(any(), any(), any()) } returns OperationImpl()
coEvery { updateApiVersions() } returns Unit
}

@MockK
Expand Down Expand Up @@ -746,6 +748,9 @@ class WireActivityViewModelTest {
@MockK
lateinit var workManager: WorkManager

@MockK
lateinit var updateApiVersions: UpdateApiVersionsUseCase

@MockK
lateinit var observeEstablishedCalls: ObserveEstablishedCallsUseCase

Expand Down Expand Up @@ -779,7 +784,8 @@ class WireActivityViewModelTest {
observeScreenshotCensoringConfigUseCaseProviderFactory = observeScreenshotCensoringConfigUseCaseProviderFactory,
globalDataStore = { globalDataStore },
observeIfE2EIRequiredDuringLoginUseCaseProviderFactory = observeIfE2EIRequiredDuringLoginUseCaseProviderFactory,
workManager = { workManager }
workManager = { workManager },
updateApiVersions = updateApiVersions
)
}

Expand Down

0 comments on commit ceabecb

Please sign in to comment.