From 66092cfa251d717a118e2c31500125a6b7ff988e Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Thu, 18 Aug 2022 09:44:18 +0200 Subject: [PATCH 1/2] Fix broken unit test on emoji search --- .../vector/app/features/reactions/data/EmojiDataSourceTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/androidTest/java/im/vector/app/features/reactions/data/EmojiDataSourceTest.kt b/vector/src/androidTest/java/im/vector/app/features/reactions/data/EmojiDataSourceTest.kt index a880b17e0c..3517f806d6 100644 --- a/vector/src/androidTest/java/im/vector/app/features/reactions/data/EmojiDataSourceTest.kt +++ b/vector/src/androidTest/java/im/vector/app/features/reactions/data/EmojiDataSourceTest.kt @@ -76,7 +76,7 @@ class EmojiDataSourceTest : InstrumentedTest { fun searchTestOneResult() { val emojiDataSource = createEmojiDataSource() val result = runBlocking { - emojiDataSource.filterWith("france") + emojiDataSource.filterWith("flag-france") } assertEquals("Should have 1 result", 1, result.size) } From 519855445e0b0669fb59d455d0ed05e9b711035a Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Wed, 17 Aug 2022 18:00:02 +0200 Subject: [PATCH 2/2] Start DM on first message when selecting "direct message" from the room member details --- changelog.d/5525.wip | 1 + .../createdirect/CreateDirectRoomViewModel.kt | 2 +- .../app/features/createdirect/DirectRoomHelper.kt | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 changelog.d/5525.wip diff --git a/changelog.d/5525.wip b/changelog.d/5525.wip new file mode 100644 index 0000000000..9ddfbab9a3 --- /dev/null +++ b/changelog.d/5525.wip @@ -0,0 +1 @@ +Create DM room only on first message - Trigger the flow when the "Direct Message" action is selected from the room member details screen diff --git a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt index b306cb6e03..36ee47ca06 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt @@ -132,10 +132,10 @@ class CreateDirectRoomViewModel @AssistedInject constructor( if (vectorFeatures.shouldStartDmOnFirstMessage()) { session.roomService().createLocalRoom(roomParams) } else { + analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse())) session.roomService().createRoom(roomParams) } } - analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse())) setState { copy( diff --git a/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt b/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt index de2027f2a5..c2cc13920f 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt @@ -16,6 +16,7 @@ package im.vector.app.features.createdirect +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 @@ -30,7 +31,8 @@ import javax.inject.Inject class DirectRoomHelper @Inject constructor( private val rawService: RawService, private val session: Session, - private val analyticsTracker: AnalyticsTracker + private val analyticsTracker: AnalyticsTracker, + private val vectorFeatures: VectorFeatures, ) { suspend fun ensureDMExists(userId: String): String { @@ -48,8 +50,12 @@ class DirectRoomHelper @Inject constructor( setDirectMessage() enableEncryptionIfInvitedUsersSupportIt = adminE2EByDefault } - roomId = session.roomService().createRoom(roomParams) - analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse())) + roomId = if (vectorFeatures.shouldStartDmOnFirstMessage()) { + session.roomService().createLocalRoom(roomParams) + } else { + analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse())) + session.roomService().createRoom(roomParams) + } } return roomId }