diff options
| author | Albin <albin@mullvad.net> | 2022-05-03 14:05:28 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2022-05-17 15:06:04 +0200 |
| commit | f2135182cea41664fdee736511035761b60140d1 (patch) | |
| tree | edbe8f9569b33610596287f74aee002a536b2512 /android/app/src | |
| parent | 35b5edc32e5d8949498d4fbb19c49a550487f5ab (diff) | |
| download | mullvadvpn-f2135182cea41664fdee736511035761b60140d1.tar.xz mullvadvpn-f2135182cea41664fdee736511035761b60140d1.zip | |
Fix Android history fetching
Diffstat (limited to 'android/app/src')
4 files changed, 17 insertions, 2 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt index 78a6baa072..e459138a0e 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/Request.kt @@ -30,6 +30,9 @@ sealed class Request : Message.RequestMessage() { object FetchAccountExpiry : Request() @Parcelize + object FetchAccountHistory : Request() + + @Parcelize object FetchAuthToken : Request() @Parcelize diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt index 018ded6fe6..8073f2220f 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt @@ -95,6 +95,12 @@ class AccountCache(private val endpoint: ServiceEndpoint) { fetchAccountExpiry() } + registerHandler(Request.FetchAccountHistory::class) { _ -> + jobTracker.newBackgroundJob("fetchAccountHistory") { + accountHistory = fetchAccountHistory() + } + } + registerHandler(Request.InvalidateAccountExpiry::class) { request -> invalidateAccountExpiry(request.expiry) } @@ -158,7 +164,7 @@ class AccountCache(private val endpoint: ServiceEndpoint) { private fun clearAccountHistory() { jobTracker.newBackgroundJob("clearAccountHistory") { daemon.await().clearAccountHistory() - fetchAccountHistory() + accountHistory = fetchAccountHistory() } } @@ -219,7 +225,7 @@ class AccountCache(private val endpoint: ServiceEndpoint) { private suspend fun doLogout() { daemon.await().logoutAccount() loginStatus = null - fetchAccountHistory() + accountHistory = fetchAccountHistory() } private fun fetchAccountHistory() { diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AccountCache.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AccountCache.kt index 6dec53cb57..4deaf4937d 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AccountCache.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/serviceconnection/AccountCache.kt @@ -74,6 +74,10 @@ class AccountCache(private val connection: Messenger, eventDispatcher: EventDisp connection.send(Request.FetchAccountExpiry.message) } + fun fetchAccountHistory() { + connection.send(Request.FetchAccountHistory.message) + } + fun invalidateAccountExpiry(accountExpiryToInvalidate: DateTime) { val request = Request.InvalidateAccountExpiry(accountExpiryToInvalidate) diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt index d064b8a91d..d4bb58d369 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/LoginViewModel.kt @@ -53,6 +53,8 @@ class LoginViewModel( _accountHistory.value = it } } + + fetchAccountHistory() } } |
