Skip to content

Commit

Permalink
Merge branch 'manage-account-button-not-working-when-offline-droid-1177'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Jul 18, 2024
2 parents 994a316 + c6f7e25 commit 1578c51
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import net.mullvad.mullvadvpn.lib.common.util.createAccountUri
import net.mullvad.mullvadvpn.lib.model.WebsiteAuthToken

@Composable
fun UriHandler.createOpenAccountPageHook(): (WebsiteAuthToken) -> Unit {
fun UriHandler.createOpenAccountPageHook(): (WebsiteAuthToken?) -> Unit {
val accountUrl = stringResource(id = R.string.account_url)
return { token -> this.openUri(createAccountUri(accountUrl, token).toString()) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ class AccountViewModel(

fun onManageAccountClick() {
viewModelScope.launch {
accountRepository.getWebsiteAuthToken()?.let { wwwAuthToken ->
_uiSideEffect.send(UiSideEffect.OpenAccountManagementPageInBrowser(wwwAuthToken))
}
val wwwAuthToken = accountRepository.getWebsiteAuthToken()
_uiSideEffect.send(UiSideEffect.OpenAccountManagementPageInBrowser(wwwAuthToken))
}
}

Expand Down Expand Up @@ -124,7 +123,8 @@ class AccountViewModel(
sealed class UiSideEffect {
data object NavigateToLogin : UiSideEffect()

data class OpenAccountManagementPageInBrowser(val token: WebsiteAuthToken) : UiSideEffect()
data class OpenAccountManagementPageInBrowser(val token: WebsiteAuthToken?) :
UiSideEffect()

data class CopyAccountNumber(val accountNumber: String) : UiSideEffect()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ class ConnectViewModel(

fun onManageAccountClick() {
viewModelScope.launch {
accountRepository.getWebsiteAuthToken()?.let { wwwAuthToken ->
_uiSideEffect.send(UiSideEffect.OpenAccountManagementPageInBrowser(wwwAuthToken))
}
val wwwAuthToken = accountRepository.getWebsiteAuthToken()
_uiSideEffect.send(UiSideEffect.OpenAccountManagementPageInBrowser(wwwAuthToken))
}
}

Expand All @@ -180,7 +179,7 @@ class ConnectViewModel(
}

sealed interface UiSideEffect {
data class OpenAccountManagementPageInBrowser(val token: WebsiteAuthToken) : UiSideEffect
data class OpenAccountManagementPageInBrowser(val token: WebsiteAuthToken?) : UiSideEffect

data object OutOfTime : UiSideEffect

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ class OutOfTimeViewModel(

fun onSitePaymentClick() {
viewModelScope.launch {
accountRepository.getWebsiteAuthToken()?.let { wwwAuthToken ->
_uiSideEffect.send(UiSideEffect.OpenAccountView(wwwAuthToken))
}
val wwwAuthToken = accountRepository.getWebsiteAuthToken()
_uiSideEffect.send(UiSideEffect.OpenAccountView(wwwAuthToken))
}
}

Expand Down Expand Up @@ -116,7 +115,7 @@ class OutOfTimeViewModel(
}

sealed interface UiSideEffect {
data class OpenAccountView(val token: WebsiteAuthToken) : UiSideEffect
data class OpenAccountView(val token: WebsiteAuthToken?) : UiSideEffect

data object OpenConnectScreen : UiSideEffect
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ class WelcomeViewModel(

fun onSitePaymentClick() {
viewModelScope.launch {
accountRepository.getWebsiteAuthToken()?.let { token ->
_uiSideEffect.send(UiSideEffect.OpenAccountView(token))
}
val wwwAuthToken = accountRepository.getWebsiteAuthToken()
_uiSideEffect.send(UiSideEffect.OpenAccountView(wwwAuthToken))
}
}

Expand Down Expand Up @@ -116,7 +115,7 @@ class WelcomeViewModel(
}

sealed interface UiSideEffect {
data class OpenAccountView(val token: WebsiteAuthToken) : UiSideEffect
data class OpenAccountView(val token: WebsiteAuthToken?) : UiSideEffect

data object OpenConnectScreen : UiSideEffect
}
Expand Down

0 comments on commit 1578c51

Please sign in to comment.