Merge pull request #997 from vector-im/feature/fga/remove_from_main_thread
Feature/fga/remove from main thread
This commit is contained in:
commit
f1d438e701
10 changed files with 41 additions and 29 deletions
|
|
@ -21,7 +21,6 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
|
|
@ -124,17 +123,12 @@ class MessagesPresenter @AssistedInject constructor(
|
|||
}
|
||||
|
||||
val inviteProgress = remember { mutableStateOf<Async<Unit>>(Async.Uninitialized) }
|
||||
|
||||
val showReinvitePrompt by remember(
|
||||
hasDismissedInviteDialog,
|
||||
composerState.hasFocus,
|
||||
syncUpdateFlow,
|
||||
) {
|
||||
derivedStateOf {
|
||||
!hasDismissedInviteDialog && composerState.hasFocus && room.isDirect && room.activeMemberCount == 1L
|
||||
var showReinvitePrompt by remember { mutableStateOf(false) }
|
||||
LaunchedEffect(hasDismissedInviteDialog, composerState.hasFocus, syncUpdateFlow) {
|
||||
withContext(dispatchers.io) {
|
||||
showReinvitePrompt = !hasDismissedInviteDialog && composerState.hasFocus && room.isDirect && room.activeMemberCount == 1L
|
||||
}
|
||||
}
|
||||
|
||||
val networkConnectionStatus by networkMonitor.connectivity.collectAsState()
|
||||
|
||||
val snackbarMessage by snackbarDispatcher.collectSnackbarMessageAsState()
|
||||
|
|
|
|||
|
|
@ -371,11 +371,15 @@ class MessagesPresenterTest {
|
|||
assertThat(initialState.showReinvitePrompt).isFalse()
|
||||
// When the input field is focused we show the alert
|
||||
initialState.composerState.eventSink(MessageComposerEvents.FocusChanged(true))
|
||||
val focusedState = awaitItem()
|
||||
val focusedState = consumeItemsUntilPredicate { state ->
|
||||
state.showReinvitePrompt
|
||||
}.last()
|
||||
assertThat(focusedState.showReinvitePrompt).isTrue()
|
||||
// If it's dismissed then we stop showing the alert
|
||||
initialState.eventSink(MessagesEvents.InviteDialogDismissed(InviteDialogAction.Cancel))
|
||||
val dismissedState = awaitItem()
|
||||
val dismissedState = consumeItemsUntilPredicate { state ->
|
||||
!state.showReinvitePrompt
|
||||
}.last()
|
||||
assertThat(dismissedState.showReinvitePrompt).isFalse()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue