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(applock): team app lock dialog displayed when changing timeout (RC) - cherrypick #2234

Merged
merged 5 commits into from
Nov 21, 2023
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 @@ -24,7 +24,6 @@ import com.wire.kalium.logic.data.featureConfig.AppLockModel
import com.wire.kalium.logic.data.featureConfig.Status
import com.wire.kalium.logic.functional.Either
import com.wire.kalium.logic.functional.nullableFold
import kotlin.time.Duration.Companion.seconds

class AppLockConfigHandler(
private val userConfigRepository: UserConfigRepository
Expand All @@ -37,8 +36,8 @@ class AppLockConfigHandler(
},
{
val newStatus = appLockConfig.status == Status.ENABLED
((it.isEnabled != newStatus) ||
(newStatus && it.timeout != appLockConfig.inactivityTimeoutSecs.seconds))
if (it.isEnabled != newStatus) true
else it.isStatusChanged
}
)
return userConfigRepository.setAppLockStatus(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AppLockConfigHandlerTest {
}

@Test
fun givenNewStatusSameAsCurrent_whenHandlingTheEvent_ThenSetAppLockWithStatusChangedFalse() {
fun givenNewStatusSameAsCurrent_whenHandlingTheEvent_ThenSetAppLockWithOldStatusChangedValue() {
val appLockModel = AppLockModel(Status.ENABLED, 44)
val (arrangement, appLockConfigHandler) = Arrangement()
.withAppLocked()
Expand All @@ -99,30 +99,7 @@ class AppLockConfigHandlerTest {
.with(
eq(appLockModel.status.toBoolean()),
eq(appLockModel.inactivityTimeoutSecs),
eq(false)
)
.wasInvoked(exactly = once)
}

@Test
fun givenStatusEnabledAndTimeoutDifferentFromCurrent_whenHandlingTheEvent_ThenSetAppLockWithStatusChangedTrue() {
val appLockModel = AppLockModel(Status.ENABLED, 20)
val (arrangement, appLockConfigHandler) = Arrangement()
.withAppLocked()
.arrange()

appLockConfigHandler.handle(appLockModel)

verify(arrangement.userConfigRepository)
.function(arrangement.userConfigRepository::isTeamAppLockEnabled)
.wasInvoked(exactly = once)

verify(arrangement.userConfigRepository)
.function(arrangement.userConfigRepository::setAppLockStatus)
.with(
eq(appLockModel.status.toBoolean()),
eq(appLockModel.inactivityTimeoutSecs),
eq(true)
eq(appLockTeamConfigEnabled.isStatusChanged)
)
.wasInvoked(exactly = once)
}
Expand Down
Loading