diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/AppLockConfigHandler.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/AppLockConfigHandler.kt index 35977292da4..d79492dd268 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/AppLockConfigHandler.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/AppLockConfigHandler.kt @@ -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 @@ -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( diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/AppLockConfigHandlerTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/AppLockConfigHandlerTest.kt index 5b98a583877..a824dc8897f 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/AppLockConfigHandlerTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/featureConfig/handler/AppLockConfigHandlerTest.kt @@ -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() @@ -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) }