Skip to content
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

fix: first Screenshot taken in the app is sometimes black #2244

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ internal class ObserveScreenshotCensoringConfigUseCaseImpl(
override suspend fun invoke(): Flow<ObserveScreenshotCensoringConfigResult> {
return combine(
userConfigRepository.observeScreenshotCensoringConfig()
.mapToRightOr(true), // for safety it's set to true if we can't determine it
.mapToRightOr(false),
userConfigRepository.observeTeamSettingsSelfDeletingStatus()
.mapRight { it.enforcedSelfDeletionTimer is TeamSelfDeleteTimer.Enforced }
.mapToRightOr(true), // for safety it's set to true if we can't determine it
.mapToRightOr(false)
) { screenshotCensoringEnabled, teamSelfDeletingEnforced ->
when {
teamSelfDeletingEnforced -> ObserveScreenshotCensoringConfigResult.Enabled.EnforcedByTeamSelfDeletingSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import io.mockative.verify
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import kotlin.time.DurationUnit
import kotlin.time.toDuration
Expand All @@ -56,7 +57,7 @@ class ObserveScreenshotCensoringConfigUseCaseTest {

result.test {
val item = awaitItem()
assertTrue { item == expectedResult }
assertEquals(expectedResult, item)

verify(arrangement.userConfigRepository)
.function(arrangement.userConfigRepository::observeScreenshotCensoringConfig)
Expand Down Expand Up @@ -89,11 +90,11 @@ class ObserveScreenshotCensoringConfigUseCaseTest {
)

@Test
fun givenSSCensoringDisabledAndTeamSelfDeletingFailure_whenInvoking_thenShouldReturnEnabledEnforcedByTeamSelfDeletingSettings() =
fun givenSSCensoringDisabledAndTeamSelfDeletingFailure_whenInvoking_thenShouldReturnDisabled() =
runTestWithParametersAndExpectedResult(
observeScreenshotCensoringConfigResult = Either.Right(false),
observeTeamSelfDeletingStatusResult = Either.Left(StorageFailure.DataNotFound),
expectedResult = ObserveScreenshotCensoringConfigResult.Enabled.EnforcedByTeamSelfDeletingSettings
expectedResult = ObserveScreenshotCensoringConfigResult.Disabled
)

@Test
Expand All @@ -113,19 +114,19 @@ class ObserveScreenshotCensoringConfigUseCaseTest {
)

@Test
fun givenSSCensoringEnabledAndTeamSelfDeletingFailure_whenInvoking_thenShouldReturnEnabledEnforcedByTeamSelfDeletingSettings() =
fun givenSSCensoringEnabledAndTeamSelfDeletingFailure_whenInvoking_thenShouldReturnEnabledChosenByUser() =
runTestWithParametersAndExpectedResult(
observeScreenshotCensoringConfigResult = Either.Right(true),
observeTeamSelfDeletingStatusResult = Either.Left(StorageFailure.DataNotFound),
expectedResult = ObserveScreenshotCensoringConfigResult.Enabled.EnforcedByTeamSelfDeletingSettings
expectedResult = ObserveScreenshotCensoringConfigResult.Enabled.ChosenByUser
)

@Test
fun givenSSCensoringFailureAndTeamSelfDeletingNotEnforced_whenInvoking_thenShouldReturnEnabledChosenByUser() =
fun givenSSCensoringFailureAndTeamSelfDeletingNotEnforced_whenInvoking_thenShouldReturnDisabled() =
runTestWithParametersAndExpectedResult(
observeScreenshotCensoringConfigResult = Either.Left(StorageFailure.DataNotFound),
observeTeamSelfDeletingStatusResult = Either.Right(TeamSelfDeleteTimer.Enabled),
expectedResult = ObserveScreenshotCensoringConfigResult.Enabled.ChosenByUser
expectedResult = ObserveScreenshotCensoringConfigResult.Disabled
)

@Test
Expand All @@ -137,11 +138,11 @@ class ObserveScreenshotCensoringConfigUseCaseTest {
)

@Test
fun givenSSCensoringFailureAndTeamSelfDeletingFailure_whenInvoking_thenShouldReturnEnabledEnforcedByTeamSelfDeletingSettings() =
fun givenSSCensoringFailureAndTeamSelfDeletingFailure_whenInvoking_thenShouldReturnDisabled() =
runTestWithParametersAndExpectedResult(
observeScreenshotCensoringConfigResult = Either.Left(StorageFailure.DataNotFound),
observeTeamSelfDeletingStatusResult = Either.Left(StorageFailure.DataNotFound),
expectedResult = ObserveScreenshotCensoringConfigResult.Enabled.EnforcedByTeamSelfDeletingSettings
expectedResult = ObserveScreenshotCensoringConfigResult.Disabled
)

private class Arrangement {
Expand Down
Loading