Skip to content

Fix missing device refresh #6344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class ConnectViewModel(
viewModelScope.launch { accountRepository.getAccountData() }
}
}
viewModelScope.launch { deviceRepository.updateDevice() }
}

fun onDisconnectClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class OutOfTimeViewModel(
}
verifyPurchases()
fetchPaymentAvailability()
viewModelScope.launch { deviceRepository.updateDevice() }
}

fun onSitePaymentClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class WelcomeViewModel(
}
verifyPurchases()
fetchPaymentAvailability()
viewModelScope.launch { deviceRepository.updateDevice() }
}

private fun hasAddedTimeEffect() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package net.mullvad.mullvadvpn.viewmodel
import androidx.lifecycle.viewModelScope
import app.cash.turbine.test
import arrow.core.right
import io.mockk.Runs
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
import io.mockk.just
import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.unmockkAll
Expand Down Expand Up @@ -102,6 +104,8 @@ class ConnectViewModelTest {

every { mockDeviceRepository.deviceState } returns device

coEvery { mockDeviceRepository.updateDevice() } just Runs

every { mockInAppNotificationController.notifications } returns notifications

every { mockConnectionProxy.tunnelState } returns tunnelState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ class ManagementService(
.map { it.toDomain() }
.mapLeft { GetDeviceStateError.Unknown(it) }

suspend fun updateDevice() {
grpc.updateDevice(Empty.getDefaultInstance())
}

suspend fun getDeviceList(token: AccountNumber): Either<GetDeviceListError, List<Device>> =
Either.catch { grpc.listDevices(StringValue.of(token.value)) }
.map { it.devicesList.map(ManagementInterface.Device::toDomain) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.mullvad.mullvadvpn.lib.shared

import android.util.Log
import arrow.core.Either
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -33,4 +34,9 @@ class DeviceRepository(

suspend fun deviceList(accountNumber: AccountNumber): Either<GetDeviceListError, List<Device>> =
managementService.getDeviceList(accountNumber)

suspend fun updateDevice() {
Log.d("mullvad", "Update device")
managementService.updateDevice()
}
}
Loading