Adapt to new DM definition changes in the SDK (#6748)

* Set `DmRoomDefinition.TwoPeople` in `ClientBuilder`. This applies the 'direct and with at most 2 non-service members' rule to what the SDK should consider a DM.

* Map `RoomInfo.isDm` from the SDK

* Map `NotificationData.isDm` from `NotificationInfo.roomInfo.isDm`

* Remove `RoomIsDmCheck` file as its extension functions are now redundant. Move `Room.isDm` helper function to `BaseRoom`.

* Map `isDm` in `SpaceRoom` from the SDK too

* Replace `isDirect` with `isDm` where possible

* Map `RoomMember.isServiceMember` from the SDK and use it to tell apart normal members of a room from service members (i.e. `RoomMembersState.getDirectRoomMember`)
This commit is contained in:
Jorge Martin Espinosa 2026-05-11 17:22:16 +02:00 committed by GitHub
parent 5e5e0bbc6e
commit 11476c73cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 115 additions and 232 deletions

View file

@ -223,7 +223,7 @@ class NotificationSettingsPresenter(
notificationSettingsService.setDefaultRoomNotificationMode(
isEncrypted = encryptedGroupDefaultMode != RoomNotificationMode.ALL_MESSAGES,
mode = RoomNotificationMode.ALL_MESSAGES,
isOneToOne = false,
isDM = false,
)
}
@ -234,7 +234,7 @@ class NotificationSettingsPresenter(
notificationSettingsService.setDefaultRoomNotificationMode(
isEncrypted = encryptedOneToOneDefaultMode != RoomNotificationMode.ALL_MESSAGES,
mode = RoomNotificationMode.ALL_MESSAGES,
isOneToOne = true,
isDM = true,
)
}
}.fold(

View file

@ -34,12 +34,12 @@ class EditDefaultNotificationSettingNode(
}
data class Inputs(
val isOneToOne: Boolean
val isDm: Boolean
) : NodeInputs
private val callback: Callback = callback()
private val inputs = inputs<Inputs>()
private val presenter = presenterFactory.create(inputs.isOneToOne)
private val presenter = presenterFactory.create(inputs.isDm)
@Composable
override fun View(modifier: Modifier) {

View file

@ -42,12 +42,12 @@ import kotlin.time.Duration.Companion.seconds
@AssistedInject
class EditDefaultNotificationSettingPresenter(
private val notificationSettingsService: NotificationSettingsService,
@Assisted private val isOneToOne: Boolean,
@Assisted private val isDm: Boolean,
private val roomListService: RoomListService,
) : Presenter<EditDefaultNotificationSettingState> {
@AssistedFactory
interface Factory {
fun create(isOneToOne: Boolean): EditDefaultNotificationSettingPresenter
fun create(isDm: Boolean): EditDefaultNotificationSettingPresenter
}
private val collator = Collator.getInstance().apply {
@ -86,7 +86,7 @@ class EditDefaultNotificationSettingPresenter(
}
return EditDefaultNotificationSettingState(
isOneToOne = isOneToOne,
isOneToOne = isDm,
mode = mode.value,
roomsWithUserDefinedMode = roomsWithUserDefinedMode.value.toImmutableList(),
changeNotificationSettingAction = changeNotificationSettingAction.value,
@ -96,7 +96,7 @@ class EditDefaultNotificationSettingPresenter(
}
private fun CoroutineScope.fetchSettings(mode: MutableState<RoomNotificationMode?>) = launch {
mode.value = notificationSettingsService.getDefaultRoomNotificationMode(isEncrypted = true, isOneToOne = isOneToOne).getOrThrow()
mode.value = notificationSettingsService.getDefaultRoomNotificationMode(isEncrypted = true, isOneToOne = isDm).getOrThrow()
}
@OptIn(FlowPreview::class)
@ -129,7 +129,7 @@ class EditDefaultNotificationSettingPresenter(
val roomWithUserDefinedRules: Set<RoomId> = notificationSettingsService.getRoomsWithUserDefinedRules().getOrDefault(emptyList()).toSet()
roomsWithUserDefinedMode.value = summaries
.filter { roomSummary ->
roomWithUserDefinedRules.contains(roomSummary.roomId) && roomSummary.isOneToOne == isOneToOne
roomWithUserDefinedRules.contains(roomSummary.roomId) && roomSummary.isDm == isDm
}
.map { roomSummary ->
EditNotificationSettingRoomInfo(
@ -154,9 +154,9 @@ class EditDefaultNotificationSettingPresenter(
private fun CoroutineScope.setDefaultNotificationMode(mode: RoomNotificationMode, action: MutableState<AsyncAction<Unit>>) = launch {
action.runUpdatingStateNoSuccess {
// On modern clients, we don't have different settings for encrypted and non-encrypted rooms (Legacy clients did).
notificationSettingsService.setDefaultRoomNotificationMode(isEncrypted = true, mode = mode, isOneToOne = isOneToOne)
notificationSettingsService.setDefaultRoomNotificationMode(isEncrypted = true, mode = mode, isDM = isDm)
.map {
notificationSettingsService.setDefaultRoomNotificationMode(isEncrypted = false, mode = mode, isOneToOne = isOneToOne)
notificationSettingsService.setDefaultRoomNotificationMode(isEncrypted = false, mode = mode, isDM = isDm)
}
}
}

View file

@ -198,7 +198,7 @@ class EditDefaultNotificationSettingsPresenterTest {
): EditDefaultNotificationSettingPresenter {
return EditDefaultNotificationSettingPresenter(
notificationSettingsService = notificationSettingsService,
isOneToOne = false,
isDm = false,
roomListService = roomListService,
)
}

View file

@ -61,8 +61,8 @@ class NotificationSettingsPresenterTest {
val notificationSettingsService = FakeNotificationSettingsService()
val presenter = createNotificationSettingsPresenter(notificationSettingsService)
presenter.test {
notificationSettingsService.setDefaultRoomNotificationMode(isEncrypted = true, isOneToOne = false, mode = RoomNotificationMode.ALL_MESSAGES)
notificationSettingsService.setDefaultRoomNotificationMode(isEncrypted = false, isOneToOne = false, mode = RoomNotificationMode.ALL_MESSAGES)
notificationSettingsService.setDefaultRoomNotificationMode(isEncrypted = true, isDM = false, mode = RoomNotificationMode.ALL_MESSAGES)
notificationSettingsService.setDefaultRoomNotificationMode(isEncrypted = false, isDM = false, mode = RoomNotificationMode.ALL_MESSAGES)
val updatedState = consumeItemsUntilPredicate {
(it.matrixSettings as? NotificationSettingsState.MatrixSettings.Valid)
?.defaultGroupNotificationMode == RoomNotificationMode.ALL_MESSAGES
@ -79,12 +79,12 @@ class NotificationSettingsPresenterTest {
presenter.test {
notificationSettingsService.setDefaultRoomNotificationMode(
isEncrypted = true,
isOneToOne = false,
isDM = false,
mode = RoomNotificationMode.ALL_MESSAGES
)
notificationSettingsService.setDefaultRoomNotificationMode(
isEncrypted = false,
isOneToOne = false,
isDM = false,
mode = RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY
)
val updatedState = consumeItemsUntilPredicate {