Skip to content

Commit

Permalink
fix: remove app lock after logout (#2378)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine committed Oct 30, 2023
1 parent 82a71f4 commit 0b2fed5
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wire.android.BuildConfig
import com.wire.android.appLogger
import com.wire.android.datastore.GlobalDataStore
import com.wire.android.datastore.UserDataStore
import com.wire.android.di.AuthServerConfigProvider
import com.wire.android.di.CurrentAccount
import com.wire.android.feature.AccountSwitchUseCase
import com.wire.android.feature.SwitchAccountActions
import com.wire.android.feature.SwitchAccountParam
import com.wire.android.feature.SwitchAccountResult
import com.wire.android.mapper.OtherAccountMapper
import com.wire.android.model.ImageAsset.UserAvatarAsset
import com.wire.android.notification.NotificationChannelsManager
Expand Down Expand Up @@ -70,6 +72,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject

// TODO cover this class with unit test
// Suppress for now after removing mockMethodForAvatar it should not complain
@Suppress("TooManyFunctions", "LongParameterList")
@HiltViewModel
Expand All @@ -91,7 +94,8 @@ class SelfUserProfileViewModel @Inject constructor(
private val endCall: EndCallUseCase,
private val isReadOnlyAccount: IsReadOnlyAccountUseCase,
private val notificationChannelsManager: NotificationChannelsManager,
private val notificationManager: WireNotificationManager
private val notificationManager: WireNotificationManager,
private val globalDataStore: GlobalDataStore
) : ViewModel() {

var userProfileState by mutableStateOf(SelfUserProfileState(userId = selfUserId, isAvatarLoading = true))
Expand Down Expand Up @@ -213,8 +217,11 @@ class SelfUserProfileViewModel @Inject constructor(

notificationManager.stopObservingOnLogout(selfUserId)
notificationChannelsManager.deleteChannelGroup(selfUserId)
accountSwitch(SwitchAccountParam.TryToSwitchToNextAccount)
.callAction(switchAccountActions)
accountSwitch(SwitchAccountParam.TryToSwitchToNextAccount).also {
if (it == SwitchAccountResult.NoOtherAccountToSwitch) {
globalDataStore.clearAppLockPasscode()
}
}.callAction(switchAccountActions)
}
}

Expand Down

0 comments on commit 0b2fed5

Please sign in to comment.