From 8fe2fc76fe8fb428337a91483342c4c29c772105 Mon Sep 17 00:00:00 2001 From: Oussama Hassine Date: Thu, 16 Nov 2023 15:34:46 +0100 Subject: [PATCH 1/2] fix(applock): team app lock dialog displayed when changing timeout --- .../feature/featureConfig/handler/AppLockConfigHandler.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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( From 1912685e3020e062360b31f236177b3d8e67495d Mon Sep 17 00:00:00 2001 From: Oussama Hassine Date: Thu, 16 Nov 2023 15:35:57 +0100 Subject: [PATCH 2/2] fix(applock): team app lock dialog displayed when changing timeout --- .../handler/AppLockConfigHandlerTest.kt | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) 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) }