1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-2261 Multiplayer | Enhancement | UX for stopping sharing space — Hotfix (#985)

This commit is contained in:
uburoiubu 2024-03-07 14:53:23 +01:00
parent cce7186873
commit 14eea20df2
No known key found for this signature in database
GPG key ID: C8FB80E0A595FBB6
3 changed files with 13 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModelProvider
import com.anytypeio.anytype.core_utils.di.scope.PerDialog
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
import com.anytypeio.anytype.di.common.ComponentDependencies
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
import com.anytypeio.anytype.domain.block.repo.BlockRepository
import com.anytypeio.anytype.domain.config.ConfigStorage
@ -49,6 +50,7 @@ object ShareSpaceModule {
interface ShareSpaceDependencies : ComponentDependencies {
fun blockRepository(): BlockRepository
fun auth() : AuthRepository
fun urlBuilder(): UrlBuilder
fun spaceManager(): SpaceManager
fun dispatchers(): AppCoroutineDispatchers

View file

@ -4,8 +4,9 @@ import com.anytypeio.anytype.core_models.Account
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
import com.anytypeio.anytype.domain.base.ResultInteractor
import javax.inject.Inject
class GetAccount(
class GetAccount @Inject constructor(
private val repo: AuthRepository,
dispatcher: AppCoroutineDispatchers
) : ResultInteractor<Unit, Account>(dispatcher.io) {

View file

@ -7,8 +7,10 @@ import com.anytypeio.anytype.core_models.Id
import com.anytypeio.anytype.core_models.ObjectWrapper
import com.anytypeio.anytype.core_models.multiplayer.ParticipantStatus
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions.OWNER
import com.anytypeio.anytype.core_models.primitives.SpaceId
import com.anytypeio.anytype.core_utils.ext.msg
import com.anytypeio.anytype.domain.auth.interactor.GetAccount
import com.anytypeio.anytype.domain.base.fold
import com.anytypeio.anytype.domain.config.ConfigStorage
import com.anytypeio.anytype.domain.library.StoreSearchParams
@ -36,7 +38,7 @@ class ShareSpaceViewModel(
private val changeSpaceMemberPermissions: ChangeSpaceMemberPermissions,
private val stopSharingSpace: StopSharingSpace,
private val container: StorelessSubscriptionContainer,
private val configStorage: ConfigStorage,
private val getAccount: GetAccount,
private val urlBuilder: UrlBuilder
) : BaseViewModel() {
@ -69,10 +71,12 @@ class ShareSpaceViewModel(
)
}
}.onEach { results ->
val account = getAccount.async(Unit).getOrNull()?.id
canStopSharing.value = results.any { result ->
val member = result.obj
member.identity == configStorage.getOrNull()?.profile
&& member.permissions == SpaceMemberPermissions.OWNER
member.identity == account && member.permissions == OWNER
}.also { isOwnerFound ->
if (!isOwnerFound) Timber.w("Owner not found")
}
}.collect {
members.value = it
@ -252,6 +256,7 @@ class ShareSpaceViewModel(
private val generateSpaceInviteLink: GenerateSpaceInviteLink,
private val changeSpaceMemberPermissions: ChangeSpaceMemberPermissions,
private val stopSharingSpace: StopSharingSpace,
private val getAccount: GetAccount,
private val removeSpaceMembers: RemoveSpaceMembers,
private val configStorage: ConfigStorage,
private val container: StorelessSubscriptionContainer,
@ -266,7 +271,7 @@ class ShareSpaceViewModel(
stopSharingSpace = stopSharingSpace,
container = container,
urlBuilder = urlBuilder,
configStorage = configStorage
getAccount = getAccount
) as T
}