Skip to content

Commit

Permalink
Merge branch 'release/candidate' into feat/grouping_message_dates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreferris authored May 6, 2024
2 parents d060f5c + a0ae53d commit c8cc34d
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cherry-pick-pr-to-newer-release-cycle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:
fetch-depth: 0

- name: Cherry pick to `develop`
uses: wireapp/[email protected].0
uses: wireapp/[email protected].1
with:
target-branch: develop
submodule-name: kalium
submodules-target-branch: develop
pr-title-suffix: 🍒
labels: cherry-pick
pr-labels: cherry-pick
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ class NotificationChannelsManager @Inject constructor(
.setImportance(NotificationManagerCompat.IMPORTANCE_DEFAULT)
.setSound(outgoingCallSoundUri, audioAttributes)
.setShowBadge(false)
.setVibrationPattern(VIBRATE_PATTERN)
.setGroup(groupId)
.build()

Expand Down
20 changes: 14 additions & 6 deletions app/src/main/kotlin/com/wire/android/ui/WireActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.wire.android.ui

import android.content.Intent
import androidx.annotation.VisibleForTesting
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
Expand Down Expand Up @@ -60,7 +61,6 @@ import com.wire.kalium.logic.data.logout.LogoutReason
import com.wire.kalium.logic.data.sync.SyncState
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.appVersioning.ObserveIfAppUpdateRequiredUseCase
import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallsUseCase
import com.wire.kalium.logic.feature.client.ClearNewClientsForUserUseCase
import com.wire.kalium.logic.feature.client.NewClientResult
import com.wire.kalium.logic.feature.client.ObserveNewClientsUseCase
Expand All @@ -78,6 +78,7 @@ import com.wire.kalium.logic.feature.user.webSocketStatus.ObservePersistentWebSo
import com.wire.kalium.util.DateTimeUtil.toIsoDateTimeString
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
Expand Down Expand Up @@ -117,8 +118,7 @@ class WireActivityViewModel @Inject constructor(
private val observeScreenshotCensoringConfigUseCaseProviderFactory: ObserveScreenshotCensoringConfigUseCaseProvider.Factory,
private val globalDataStore: GlobalDataStore,
private val observeIfE2EIRequiredDuringLoginUseCaseProviderFactory: ObserveIfE2EIRequiredDuringLoginUseCaseProvider.Factory,
private val workManager: WorkManager,
private val observeEstablishedCalls: ObserveEstablishedCallsUseCase
private val workManager: WorkManager
) : ViewModel() {

var globalAppState: GlobalAppState by mutableStateOf(GlobalAppState())
Expand Down Expand Up @@ -257,7 +257,15 @@ class WireActivityViewModel @Inject constructor(
return intent?.action == Intent.ACTION_SEND || intent?.action == Intent.ACTION_SEND_MULTIPLE
}

private suspend fun canLoginThroughDeepLinks() = observeEstablishedCalls().first().isEmpty()
@VisibleForTesting
internal suspend fun canLoginThroughDeepLinks() = viewModelScope.async {
coreLogic.getGlobalScope().session.currentSession().takeIf {
it is CurrentSessionResult.Success
}?.let {
val currentUserId = (it as CurrentSessionResult.Success).accountInfo.userId
coreLogic.getSessionScope(currentUserId).calls.establishedCall().first().isEmpty()
} ?: true
}

@Suppress("ComplexMethod")
fun handleDeepLink(
Expand All @@ -276,15 +284,15 @@ class WireActivityViewModel @Inject constructor(
val result = intent?.data?.let { deepLinkProcessor(it) }
when {
result is DeepLinkResult.SSOLogin -> {
if (canLoginThroughDeepLinks()) {
if (canLoginThroughDeepLinks().await()) {
onResult(result)
} else {
onCannotLoginDuringACall()
}
}
result is DeepLinkResult.MigrationLogin -> onResult(result)
result is DeepLinkResult.CustomServerConfig -> {
if (canLoginThroughDeepLinks()) {
if (canLoginThroughDeepLinks().await()) {
onCustomServerConfig(result)
} else {
onCannotLoginDuringACall()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class SharedCallingViewModel @AssistedInject constructor(
if (callState.isCameraOn) {
flipToFrontCamera(conversationId)
}
if (callState.isCameraOn || callState.isSpeakerOn) {
if (callState.isSpeakerOn) {
turnLoudSpeakerOff()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fun IncomingCallScreen(
LaunchedEffect(incomingCallViewModel.incomingCallState.flowState) {
when (incomingCallViewModel.incomingCallState.flowState) {
is IncomingCallState.FlowState.CallClosed -> {
activity.finish()
activity.finishAndRemoveTask()
}

is IncomingCallState.FlowState.CallAccepted -> {
Expand All @@ -132,7 +132,7 @@ fun IncomingCallScreen(
(activity as CallActivity).openAppLockActivity()
},
onCallRejected = {
activity.finish()
activity.finishAndRemoveTask()
}
)
},
Expand All @@ -150,7 +150,7 @@ fun IncomingCallScreen(
}
},
onMinimiseScreen = {
activity.finish()
activity.moveTaskToBack(true)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fun OngoingCallScreen(
LaunchedEffect(ongoingCallViewModel.state.flowState) {
when (ongoingCallViewModel.state.flowState) {
OngoingCallState.FlowState.CallClosed -> {
activity.finish()
activity.finishAndRemoveTask()
}

OngoingCallState.FlowState.Default -> { /* do nothing */
Expand All @@ -134,7 +134,7 @@ fun OngoingCallScreen(
shouldShowDoubleTapToast = ongoingCallViewModel.shouldShowDoubleTapToast,
toggleSpeaker = sharedCallingViewModel::toggleSpeaker,
toggleMute = sharedCallingViewModel::toggleMute,
hangUpCall = { sharedCallingViewModel.hangUpCall { activity.finish() } },
hangUpCall = { sharedCallingViewModel.hangUpCall { activity.finishAndRemoveTask() } },
toggleVideo = sharedCallingViewModel::toggleVideo,
flipCamera = sharedCallingViewModel::flipCamera,
setVideoPreview = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fun OutgoingCallScreen(
LaunchedEffect(outgoingCallViewModel.state.flowState) {
when (outgoingCallViewModel.state.flowState) {
OutgoingCallState.FlowState.CallClosed -> {
activity.finish()
activity.finishAndRemoveTask()
}

OutgoingCallState.FlowState.CallEstablished -> {
Expand Down Expand Up @@ -105,7 +105,7 @@ fun OutgoingCallScreen(
}
},
onMinimiseScreen = {
activity.finish()
activity.moveTaskToBack(true)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class MessageComposerStateHolder(
}

fun toReply(message: UIMessage.Regular) {
messageCompositionHolder.clearMessage()
messageCompositionHolder.setReply(message)
messageCompositionInputStateHolder.toComposing()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,44 @@ class WireActivityViewModelTest {
assertEquals(ThemeOption.DARK, viewModel.globalAppState.themeOption)
}

@Test
fun `given no active session, when canLoginThroughDeepLinks is called, then return true`() =
runTest {
val (_, viewModel) = Arrangement()
.withNoCurrentSession()
.arrange()

val result = viewModel.canLoginThroughDeepLinks()

result.await() `should be equal to` true
}

@Test
fun `given an established call, when canLoginThroughDeepLinks is called, then return false`() =
runTest {
val (_, viewModel) = Arrangement()
.withSomeCurrentSession()
.withOngoingCall()
.arrange()

val result = viewModel.canLoginThroughDeepLinks()

result.await() `should be equal to` false
}

@Test
fun `given no established call, when canLoginThroughDeepLinks is called, then return true`() =
runTest {
val (_, viewModel) = Arrangement()
.withNoCurrentSession()
.withNoOngoingCall()
.arrange()

val result = viewModel.canLoginThroughDeepLinks()

result.await() `should be equal to` true
}

private class Arrangement {

init {
Expand Down Expand Up @@ -722,8 +760,7 @@ class WireActivityViewModelTest {
observeScreenshotCensoringConfigUseCaseProviderFactory = observeScreenshotCensoringConfigUseCaseProviderFactory,
globalDataStore = globalDataStore,
observeIfE2EIRequiredDuringLoginUseCaseProviderFactory = observeIfE2EIRequiredDuringLoginUseCaseProviderFactory,
workManager = workManager,
observeEstablishedCalls = observeEstablishedCalls
workManager = workManager
)
}

Expand All @@ -746,10 +783,12 @@ class WireActivityViewModelTest {
}

fun withNoOngoingCall(): Arrangement {
coEvery { coreLogic.getSessionScope(any()).calls.establishedCall } returns observeEstablishedCalls
coEvery { observeEstablishedCalls() } returns flowOf(emptyList())
return this
}
fun withOngoingCall(): Arrangement {
coEvery { coreLogic.getSessionScope(any()).calls.establishedCall } returns observeEstablishedCalls
coEvery { observeEstablishedCalls() } returns flowOf(listOf(ongoingCall))
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ class MessageComposerStateHolderTest {
runTest {
// given
// when
state.toReply(
message = mockMessageWithText
)
state.toReply(mockMessageWithText)

// then
assertEquals(
Expand All @@ -133,6 +131,22 @@ class MessageComposerStateHolderTest {
)
}

@Test
fun `given some message was being composed, when setting toReply, then input continues with the current text`() = runTest {
// given
val currentTextField = TextFieldValue("Potato")
messageCompositionHolder.setMessageText(currentTextField, {}, {}, {})

// when
state.toReply(mockMessageWithText)

// then
assertEquals(
currentTextField.text,
messageCompositionHolder.messageComposition.value.messageTextFieldValue.text
)
}

@Test
fun `given state, when input focus change to false, then clear focus`() = runTest {
// given
Expand Down

0 comments on commit c8cc34d

Please sign in to comment.