-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Ask User for call quality feedback [WPB-9452] #2966
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cd092cb
feat: Ask User for Call quality feedback
borichellow e720f5b
Merge branch 'develop' into feat/ask_user_for_call_quality_feedback
borichellow 4e760db
Code-style fix
borichellow b17f844
Review fixes
borichellow d4c9b50
Merge branch 'develop' into feat/ask_user_for_call_quality_feedback
borichellow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
42 changes: 42 additions & 0 deletions
42
...onMain/kotlin/com/wire/kalium/logic/feature/call/usecase/ObserveAskCallFeedbackUseCase.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,42 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 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.filterIsInstance | ||
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 ObserveAskCallFeedbackUseCase { | ||
/** | ||
* @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<Boolean> | ||
} | ||
|
||
@Suppress("FunctionNaming") | ||
internal fun ObserveAskCallFeedbackUseCase( | ||
endCallListener: EndCallResultListener | ||
) = object : ObserveAskCallFeedbackUseCase { | ||
override suspend fun invoke(): Flow<Boolean> = | ||
endCallListener.observeCallEndedResult() | ||
.filterIsInstance(EndCallResult.AskForFeedback::class) | ||
.map { it.shouldAsk } | ||
} |
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
46 changes: 46 additions & 0 deletions
46
.../src/commonMain/kotlin/com/wire/kalium/logic/feature/user/ShouldAskCallFeedbackUseCase.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,46 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 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.user | ||
|
||
import com.wire.kalium.logic.configuration.UserConfigRepository | ||
import com.wire.kalium.logic.functional.getOrElse | ||
import com.wire.kalium.logic.functional.map | ||
import com.wire.kalium.util.DateTimeUtil | ||
import kotlinx.datetime.Instant | ||
|
||
/** | ||
* Use case that returns [Boolean] if user should be asked for a feedback about call quality or not. | ||
*/ | ||
interface ShouldAskCallFeedbackUseCase { | ||
/** | ||
* @return [Boolean] if user should be asked for a feedback about call quality or not. | ||
*/ | ||
suspend operator fun invoke(): Boolean | ||
} | ||
|
||
@Suppress("FunctionNaming") | ||
internal fun ShouldAskCallFeedbackUseCase( | ||
userConfigRepository: UserConfigRepository | ||
) = object : ShouldAskCallFeedbackUseCase { | ||
|
||
override suspend fun invoke(): Boolean = | ||
userConfigRepository.getNextTimeForCallFeedback().map { | ||
it > 0L && DateTimeUtil.currentInstant() > Instant.fromEpochMilliseconds(it) | ||
}.getOrElse(true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...commonMain/kotlin/com/wire/kalium/logic/feature/user/UpdateNextTimeCallFeedbackUseCase.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,52 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 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.user | ||
|
||
import com.wire.kalium.logic.configuration.UserConfigRepository | ||
import com.wire.kalium.logic.feature.user.UpdateNextTimeCallFeedbackUseCase.Companion.askingForFeedbackPeriod | ||
import com.wire.kalium.util.DateTimeUtil | ||
import kotlin.time.Duration.Companion.days | ||
|
||
/** | ||
* Use case that updates next time when user should be asked for a feedback about call quality. | ||
*/ | ||
interface UpdateNextTimeCallFeedbackUseCase { | ||
/** | ||
* Update next time when user should be asked for a feedback about call quality. | ||
* @param neverAskAgain [Boolean] if user checked "never ask me again" | ||
*/ | ||
suspend operator fun invoke(neverAskAgain: Boolean) | ||
|
||
companion object { | ||
val askingForFeedbackPeriod = 3.days | ||
} | ||
} | ||
|
||
@Suppress("FunctionNaming") | ||
internal fun UpdateNextTimeCallFeedbackUseCase( | ||
userConfigRepository: UserConfigRepository | ||
) = object : UpdateNextTimeCallFeedbackUseCase { | ||
|
||
override suspend fun invoke(neverAskAgain: Boolean) { | ||
val nextTimestamp = if (neverAskAgain) -1L | ||
else DateTimeUtil.currentInstant().plus(askingForFeedbackPeriod).toEpochMilliseconds() | ||
|
||
userConfigRepository.updateNextTimeForCallFeedback(nextTimestamp) | ||
} | ||
|
||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍