mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3659 Multiplayer | Support link without approve, fixes (#2445)
This commit is contained in:
parent
55e430c70b
commit
bd9ccaff50
4 changed files with 101 additions and 9 deletions
|
@ -28,7 +28,6 @@ import com.anytypeio.anytype.presentation.common.BaseViewModel
|
|||
import com.anytypeio.anytype.presentation.common.TypedViewState
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -54,6 +53,7 @@ class RequestJoinSpaceViewModel(
|
|||
val commands = MutableSharedFlow<Command>(0)
|
||||
val showLoadingInviteProgress = MutableStateFlow(false)
|
||||
private var getSpaceInviteViewJob: Job? = null
|
||||
private var joinSpaceRequestJob: Job? = null
|
||||
|
||||
init {
|
||||
Timber.i("RequestJoinSpaceViewModel, init")
|
||||
|
@ -132,7 +132,8 @@ class RequestJoinSpaceViewModel(
|
|||
fun onRequestToJoinClicked() {
|
||||
when(val curr = state.value) {
|
||||
is TypedViewState.Success -> {
|
||||
viewModelScope.launch {
|
||||
joinSpaceRequestJob?.cancel()
|
||||
joinSpaceRequestJob = viewModelScope.launch {
|
||||
val fileKey = spaceInviteResolver.parseFileKey(params.link)
|
||||
val contentId = spaceInviteResolver.parseContentId(params.link)
|
||||
if (contentId != null && fileKey != null) {
|
||||
|
@ -156,10 +157,14 @@ class RequestJoinSpaceViewModel(
|
|||
onSuccess = {
|
||||
analytics.sendEvent(eventName = screenRequestSent)
|
||||
if (notificator.areNotificationsEnabled) {
|
||||
commands.emit(Command.Toast.RequestSent)
|
||||
if (!curr.data.withoutApprove) {
|
||||
commands.emit(Command.Toast.RequestSent)
|
||||
}
|
||||
commands.emit(Command.Dismiss)
|
||||
} else {
|
||||
commands.emit(Command.Toast.RequestSent)
|
||||
if (!curr.data.withoutApprove) {
|
||||
commands.emit(Command.Toast.RequestSent)
|
||||
}
|
||||
showEnableNotificationDialog.value = true
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +178,11 @@ class RequestJoinSpaceViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun onCancelJoinSpaceRequestClicked() {
|
||||
joinSpaceRequestJob?.cancel()
|
||||
isRequestInProgress.value = false
|
||||
}
|
||||
|
||||
fun onOpenSpaceClicked(space: SpaceId) {
|
||||
viewModelScope.launch {
|
||||
val curr = spaceManager.get()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue