Skip to content

Commit

Permalink
extract mapping to it's own function
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadJaara committed Jul 8, 2024
1 parent c500367 commit f981c2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 11 additions & 0 deletions app/src/main/kotlin/com/wire/android/ui/home/FeatureFlagState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.wire.android.ui.home

import com.wire.android.ui.home.messagecomposer.SelfDeletionDuration
import com.wire.kalium.logic.configuration.FileSharingStatus
import kotlin.time.Duration

data class FeatureFlagState(
Expand Down Expand Up @@ -67,3 +68,13 @@ data class FeatureFlagState(
data class Success(val certificate: String) : E2EIResult()
}
}

fun FileSharingStatus.Value.toFeatureFlagState(): FeatureFlagState.FileSharingState {
return when (this) {
FileSharingStatus.Value.Disabled -> FeatureFlagState.FileSharingState.DisabledByTeam
FileSharingStatus.Value.EnabledAll -> FeatureFlagState.FileSharingState.AllowAll
is FileSharingStatus.Value.EnabledSome -> FeatureFlagState.FileSharingState.AllowSome(
allowedType
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import com.wire.android.feature.DisableAppLockUseCase
import com.wire.android.ui.home.FeatureFlagState
import com.wire.android.ui.home.conversations.selfdeletion.SelfDeletionMapper.toSelfDeletionDuration
import com.wire.android.ui.home.messagecomposer.SelfDeletionDuration
import com.wire.android.ui.home.toFeatureFlagState
import com.wire.kalium.logic.CoreFailure
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.configuration.FileSharingStatus
import com.wire.kalium.logic.data.message.TeamSelfDeleteTimer
import com.wire.kalium.logic.data.sync.SyncState
import com.wire.kalium.logic.data.user.UserId
Expand Down Expand Up @@ -132,13 +132,7 @@ class FeatureFlagNotificationViewModel @Inject constructor(

private suspend fun setFileSharingState(userId: UserId) {
coreLogic.getSessionScope(userId).observeFileSharingStatus().collect { fileSharingStatus ->
val state: FeatureFlagState.FileSharingState = when (fileSharingStatus.state) {
FileSharingStatus.Value.Disabled -> FeatureFlagState.FileSharingState.DisabledByTeam
FileSharingStatus.Value.EnabledAll -> FeatureFlagState.FileSharingState.AllowAll
is FileSharingStatus.Value.EnabledSome -> FeatureFlagState.FileSharingState.AllowSome(
(fileSharingStatus.state as FileSharingStatus.Value.EnabledSome).allowedType
)
}
val state: FeatureFlagState.FileSharingState = fileSharingStatus.state.toFeatureFlagState()
featureFlagState = featureFlagState.copy(
isFileSharingState = state,
showFileSharingDialog = fileSharingStatus.isStatusChanged ?: false
Expand Down

0 comments on commit f981c2a

Please sign in to comment.