mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
App | Fix | About-app screen should display anytype user id instead of profile object id (#2172)
This commit is contained in:
parent
c49dae3c99
commit
bb9dbcbc71
5 changed files with 24 additions and 14 deletions
|
@ -5,6 +5,7 @@
|
|||
### Fixes & tech 🚒
|
||||
|
||||
* Editor | Fix inconsistent toggle icon state (#2164)
|
||||
* App | Fix | About-app screen should display Anytype user ID instead of profile object ID (#2172)
|
||||
|
||||
## Version 0.6.1
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.anytypeio.anytype.di.feature.settings
|
||||
|
||||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetCurrentAccount
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetAccount
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetLibraryVersion
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
import com.anytypeio.anytype.ui.settings.AboutAppFragment
|
||||
import com.anytypeio.anytype.ui_settings.about.AboutAppViewModel
|
||||
import dagger.Module
|
||||
|
@ -32,10 +30,10 @@ object AboutAppModule {
|
|||
@Provides
|
||||
@PerScreen
|
||||
fun provideViewModelFactory(
|
||||
getCurrentAccount: GetCurrentAccount,
|
||||
getAccount: GetAccount,
|
||||
getLibraryVersion: GetLibraryVersion
|
||||
): AboutAppViewModel.Factory = AboutAppViewModel.Factory(
|
||||
getCurrentAccount = getCurrentAccount,
|
||||
getAccount = getAccount,
|
||||
getLibraryVersion = getLibraryVersion
|
||||
)
|
||||
|
||||
|
@ -43,9 +41,8 @@ object AboutAppModule {
|
|||
@Provides
|
||||
@PerScreen
|
||||
fun provideGetAccountUseCase(
|
||||
repo: BlockRepository,
|
||||
builder: UrlBuilder
|
||||
): GetCurrentAccount = GetCurrentAccount(repo = repo, builder = builder)
|
||||
repo: AuthRepository
|
||||
): GetAccount = GetAccount(repo = repo)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.anytypeio.anytype.domain.auth.interactor
|
||||
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
|
||||
class GetAccount(
|
||||
private val repo: AuthRepository
|
||||
) : BaseUseCase<Account, BaseUseCase.None>() {
|
||||
override suspend fun run(params: None) = safe { repo.getCurrentAccount() }
|
||||
}
|
|
@ -1,14 +1,15 @@
|
|||
package com.anytypeio.anytype.domain.auth.interactor
|
||||
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.domain.auth.model.Account
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import com.anytypeio.anytype.domain.base.Either
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
import com.anytypeio.anytype.core_models.Event
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
|
||||
/** Use case for getting currently selected user account.
|
||||
*/
|
||||
@Deprecated("Incorrect use-case. Will be deleted.")
|
||||
class GetCurrentAccount(
|
||||
private val repo: BlockRepository,
|
||||
private val builder: UrlBuilder
|
||||
|
|
|
@ -3,14 +3,14 @@ package com.anytypeio.anytype.ui_settings.about
|
|||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetCurrentAccount
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetAccount
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetLibraryVersion
|
||||
import com.anytypeio.anytype.domain.base.BaseUseCase
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class AboutAppViewModel(
|
||||
private val getCurrentAccount: GetCurrentAccount,
|
||||
private val getAccount: GetAccount,
|
||||
private val getLibraryVersion: GetLibraryVersion
|
||||
) : ViewModel() {
|
||||
|
||||
|
@ -19,7 +19,7 @@ class AboutAppViewModel(
|
|||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
getCurrentAccount(BaseUseCase.None).process(
|
||||
getAccount(BaseUseCase.None).process(
|
||||
failure = {},
|
||||
success = { acc ->
|
||||
userId.value = acc.id
|
||||
|
@ -37,14 +37,14 @@ class AboutAppViewModel(
|
|||
}
|
||||
|
||||
class Factory(
|
||||
private val getCurrentAccount: GetCurrentAccount,
|
||||
private val getAccount: GetAccount,
|
||||
private val getLibraryVersion: GetLibraryVersion
|
||||
) : ViewModelProvider.Factory {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||
return AboutAppViewModel(
|
||||
getCurrentAccount = getCurrentAccount,
|
||||
getAccount = getAccount,
|
||||
getLibraryVersion = getLibraryVersion
|
||||
) as T
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue