-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: End call on verification degradation (WPB-4487) (#2199)
* feat: End call on verification degradation * Fixed tests * Renamed some classes * Review changes * Fixed test * Renamed useCase * Fixed code style
- Loading branch information
1 parent
19b3723
commit 33129c1
Showing
7 changed files
with
341 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...src/commonMain/kotlin/com/wire/kalium/logic/feature/call/usecase/EndCallResultListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.call.usecase | ||
|
||
import com.wire.kalium.logic.data.id.ConversationId | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
|
||
interface EndCallResultListener { | ||
suspend fun observeCallEndedBecauseOfVerificationDegraded(): Flow<ConversationId> | ||
suspend fun onCallEndedBecauseOfVerificationDegraded(conversationId: ConversationId) | ||
} | ||
|
||
/** | ||
* This singleton allow us to queue event to show dialog informing user that call was ended because of verification degradation. | ||
*/ | ||
object EndCallResultListenerImpl : EndCallResultListener { | ||
|
||
private val conversationCallEnded = MutableSharedFlow<ConversationId>() | ||
|
||
override suspend fun observeCallEndedBecauseOfVerificationDegraded(): Flow<ConversationId> = conversationCallEnded | ||
|
||
override suspend fun onCallEndedBecauseOfVerificationDegraded(conversationId: ConversationId) { | ||
conversationCallEnded.emit(conversationId) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...re/kalium/logic/feature/call/usecase/ObserveEndCallDueToConversationDegradationUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2023 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.call.usecase | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
|
||
/** | ||
* The useCase for observing when the ongoing call was ended because of degradation of conversation verification status (Proteus or MLS) | ||
*/ | ||
interface ObserveEndCallDueToConversationDegradationUseCase { | ||
/** | ||
* @return [Flow] that emits only when the call was ended because of degradation of conversation verification status (Proteus or MLS) | ||
*/ | ||
suspend operator fun invoke(): Flow<Unit> | ||
} | ||
|
||
internal class ObserveEndCallDueToConversationDegradationUseCaseImpl( | ||
private val endCallListener: EndCallResultListener | ||
) : ObserveEndCallDueToConversationDegradationUseCase { | ||
override suspend fun invoke(): Flow<Unit> = | ||
endCallListener.observeCallEndedBecauseOfVerificationDegraded().map { Unit } | ||
} |
Oops, something went wrong.