Let RoomMemberDetailsPresenter use UserProfilePresenter to reduce code duplication.

This commit is contained in:
Benoit Marty 2024-10-17 13:10:59 +02:00 committed by Benoit Marty
parent 77e874b906
commit 95a7cf643e
18 changed files with 153 additions and 368 deletions

View file

@ -0,0 +1,17 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/
package io.element.android.features.userprofile.api
sealed interface UserProfileEvents {
data object StartDM : UserProfileEvents
data object ClearStartDMState : UserProfileEvents
data class BlockUser(val needsConfirmation: Boolean = false) : UserProfileEvents
data class UnblockUser(val needsConfirmation: Boolean = false) : UserProfileEvents
data object ClearBlockUserError : UserProfileEvents
data object ClearConfirmationDialog : UserProfileEvents
}

View file

@ -0,0 +1,31 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/
package io.element.android.features.userprofile.api
import io.element.android.libraries.architecture.AsyncAction
import io.element.android.libraries.architecture.AsyncData
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.core.UserId
data class UserProfileState(
val userId: UserId,
val userName: String?,
val avatarUrl: String?,
val isBlocked: AsyncData<Boolean>,
val startDmActionState: AsyncAction<RoomId>,
val displayConfirmationDialog: ConfirmationDialog?,
val isCurrentUser: Boolean,
val dmRoomId: RoomId?,
val canCall: Boolean,
val eventSink: (UserProfileEvents) -> Unit
) {
enum class ConfirmationDialog {
Block,
Unblock
}
}

View file

@ -0,0 +1,15 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/
package io.element.android.features.userprofile.api
import io.element.android.libraries.architecture.Presenter
import io.element.android.libraries.matrix.api.core.UserId
fun interface UserProfileStatePresenterFactory {
fun create(userId: UserId): Presenter<UserProfileState>
}