Skip to content

Can't backup data | No way to upgrade from an anonymous account ? #162

@vitto4

Description

@vitto4

Hi there !

I believe there's an issue with the way anonymous accounts are handled, that would prevent from upgrading to a full account.
This is especially problematic when you want to backup your data to migrate to a new device, since no backup option is available (relevant issue #160).

Steps to reproduce

  • On a fresh install, open the app. You are greeted by the login screen.
  • Click Skip this for now. It states You can always upgrade to a regular account later on. ; click Login.
  • On the main menu, click on the button.

Expected result : A button to upgrade to a full account is shown

Actual result : No action is shown in the user section


I have never worked with Kotlin so I may very well be wrong here, but I believe the issue stems from the fact that despite the code being present in at.shockbytes.dante.ui.custom.profile.ProfileActionViewState

fun forAnonymousUser(): ProfileActionViewState {
return Visible(
showUpgrade = true,
showChangeName = true,
showChangeImage = true,
showChangePassword = false
)
}

The line AuthenticationSource.ANONYMOUS -> ProfileActionViewState.forAnonymousUser() is never reached in at.shockbytes.dante.ui.viewmodel.UserViewModel

private fun mapUserStateToUserEvent(userState: UserState) = when (userState) {
is UserState.SignedInUser -> {
UserViewState.LoggedIn(userState.user, resolveProfileActionViewState(userState.user))
}
is UserState.Unauthenticated -> {
UserViewState.UnauthenticatedUser
}
}
private fun resolveProfileActionViewState(user: DanteUser): ProfileActionViewState {
return when (user.authenticationSource) {
AuthenticationSource.GOOGLE -> ProfileActionViewState.forGoogleUser()
AuthenticationSource.MAIL -> ProfileActionViewState.forMailUser()
AuthenticationSource.ANONYMOUS -> ProfileActionViewState.forAnonymousUser()
else -> ProfileActionViewState.Hidden
}
}

Because anonymous accounts seem to be treated as UserState.Unauthenticated. It is not exactly clear to me why that is the case though.
As a result, the relevant buttons are not shown in the menu :

is UserViewModel.UserViewState.UnauthenticatedUser -> {
vb.btnMenuLogin.text = getString(R.string.login)
vb.profileActionViewMenu.setState(ProfileActionViewState.Hidden)
vb.profileHeaderMenu.reset()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions