mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Start DM - Add feature flag
This commit is contained in:
parent
3dcec85dea
commit
c9ab0927f0
@ -70,6 +70,11 @@ class DebugFeaturesStateFactory @Inject constructor(
|
||||
key = DebugFeatureKeys.allowExternalUnifiedPushDistributors,
|
||||
factory = VectorFeatures::allowExternalUnifiedPushDistributors
|
||||
),
|
||||
createBooleanFeature(
|
||||
label = "Start DM on first message",
|
||||
key = DebugFeatureKeys.startDmOnFirstMsg,
|
||||
factory = VectorFeatures::shouldStartDmOnFirstMessage
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -66,6 +66,9 @@ class DebugVectorFeatures(
|
||||
override fun isScreenSharingEnabled(): Boolean = read(DebugFeatureKeys.screenSharing)
|
||||
?: vectorFeatures.isScreenSharingEnabled()
|
||||
|
||||
override fun shouldStartDmOnFirstMessage(): Boolean = read(DebugFeatureKeys.startDmOnFirstMsg)
|
||||
?: vectorFeatures.shouldStartDmOnFirstMessage()
|
||||
|
||||
fun <T> override(value: T?, key: Preferences.Key<T>) = updatePreferences {
|
||||
if (value == null) {
|
||||
it.remove(key)
|
||||
@ -123,4 +126,5 @@ object DebugFeatureKeys {
|
||||
val allowExternalUnifiedPushDistributors = booleanPreferencesKey("allow-external-unified-push-distributors")
|
||||
val liveLocationSharing = booleanPreferencesKey("live-location-sharing")
|
||||
val screenSharing = booleanPreferencesKey("screen-sharing")
|
||||
val startDmOnFirstMsg = booleanPreferencesKey("start-dm-on-first-msg")
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ interface VectorFeatures {
|
||||
fun isOnboardingCombinedLoginEnabled(): Boolean
|
||||
fun allowExternalUnifiedPushDistributors(): Boolean
|
||||
fun isScreenSharingEnabled(): Boolean
|
||||
fun shouldStartDmOnFirstMessage(): Boolean
|
||||
|
||||
enum class OnboardingVariant {
|
||||
LEGACY,
|
||||
@ -48,4 +49,5 @@ class DefaultVectorFeatures : VectorFeatures {
|
||||
override fun isOnboardingCombinedLoginEnabled() = false
|
||||
override fun allowExternalUnifiedPushDistributors(): Boolean = Config.ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS
|
||||
override fun isScreenSharingEnabled(): Boolean = true
|
||||
override fun shouldStartDmOnFirstMessage(): Boolean = false
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.mvrx.runCatchingToAsync
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.features.VectorFeatures
|
||||
import im.vector.app.features.analytics.AnalyticsTracker
|
||||
import im.vector.app.features.analytics.plan.CreatedRoom
|
||||
import im.vector.app.features.raw.wellknown.getElementWellknown
|
||||
@ -46,7 +47,8 @@ class CreateDirectRoomViewModel @AssistedInject constructor(
|
||||
@Assisted initialState: CreateDirectRoomViewState,
|
||||
private val rawService: RawService,
|
||||
val session: Session,
|
||||
val analyticsTracker: AnalyticsTracker
|
||||
val analyticsTracker: AnalyticsTracker,
|
||||
val vectorFeatures: VectorFeatures
|
||||
) :
|
||||
VectorViewModel<CreateDirectRoomViewState, CreateDirectRoomAction, CreateDirectRoomViewEvents>(initialState) {
|
||||
|
||||
@ -124,7 +126,12 @@ class CreateDirectRoomViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
val result = runCatchingToAsync {
|
||||
session.roomService().createRoom(roomParams)
|
||||
if (vectorFeatures.shouldStartDmOnFirstMessage()) {
|
||||
// Todo: Prepare direct room creation
|
||||
throw Throwable("Start DM on first message is not implemented yet.")
|
||||
} else {
|
||||
session.roomService().createRoom(roomParams)
|
||||
}
|
||||
}
|
||||
analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse()))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user