Update room properties from room details (#439)
- Add the edit action in the room details
- Add "Add topic" button in room details
- Add the screen behind that action to edit some room properties: avatar, name, topic
- Handle the save button action
- enable the button only if changes are detected
- display a loader "updating room"
- display an error dialog if any request has failed
- Check user has the right power level to change various attributes
- "Add topic" is only shown if there's no topic and they are able to set on
- Edit menu is only shown if they can change topic, name or avatar
- On the edit page, any fields they can't change are uneditable
Co-authored-by: Chris Smith <csmith@lunarian.uk>
This commit is contained in:
parent
5de90c3871
commit
5d0fb45ff6
100 changed files with 2031 additions and 219 deletions
|
|
@ -26,6 +26,7 @@ import io.element.android.libraries.matrix.api.media.ImageInfo
|
|||
import io.element.android.libraries.matrix.api.media.VideoInfo
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoomMembersState
|
||||
import io.element.android.libraries.matrix.api.room.StateEventType
|
||||
import io.element.android.libraries.matrix.api.timeline.MatrixTimeline
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||
|
|
@ -62,7 +63,13 @@ class FakeMatrixRoom(
|
|||
private var rejectInviteResult = Result.success(Unit)
|
||||
private var inviteUserResult = Result.success(Unit)
|
||||
private var canInviteResult = Result.success(true)
|
||||
private val canSendStateResults = mutableMapOf<StateEventType, Result<Boolean>>()
|
||||
private var sendMediaResult = Result.success(Unit)
|
||||
private var setNameResult = Result.success(Unit)
|
||||
private var setTopicResult = Result.success(Unit)
|
||||
private var updateAvatarResult = Result.success(Unit)
|
||||
private var removeAvatarResult = Result.success(Unit)
|
||||
|
||||
var sendMediaCount = 0
|
||||
private set
|
||||
|
||||
|
|
@ -75,6 +82,18 @@ class FakeMatrixRoom(
|
|||
var invitedUserId: UserId? = null
|
||||
private set
|
||||
|
||||
var newTopic: String? = null
|
||||
private set
|
||||
|
||||
var newName: String? = null
|
||||
private set
|
||||
|
||||
var newAvatarData: ByteArray? = null
|
||||
private set
|
||||
|
||||
var removedAvatar: Boolean = false
|
||||
private set
|
||||
|
||||
private var leaveRoomError: Throwable? = null
|
||||
|
||||
override val membersStateFlow: MutableStateFlow<MatrixRoomMembersState> = MutableStateFlow(MatrixRoomMembersState.Unknown)
|
||||
|
|
@ -151,6 +170,10 @@ class FakeMatrixRoom(
|
|||
return canInviteResult
|
||||
}
|
||||
|
||||
override suspend fun canSendStateEvent(type: StateEventType): Result<Boolean> {
|
||||
return canSendStateResults[type] ?: Result.failure(IllegalStateException("No fake answer"))
|
||||
}
|
||||
|
||||
override suspend fun sendImage(file: File, thumbnailFile: File, imageInfo: ImageInfo): Result<Unit> = fakeSendMedia()
|
||||
|
||||
override suspend fun sendVideo(file: File, thumbnailFile: File, videoInfo: VideoInfo): Result<Unit> = fakeSendMedia()
|
||||
|
|
@ -166,6 +189,26 @@ class FakeMatrixRoom(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun updateAvatar(mimeType: String, data: ByteArray): Result<Unit> {
|
||||
newAvatarData = data
|
||||
return updateAvatarResult
|
||||
}
|
||||
|
||||
override suspend fun removeAvatar(): Result<Unit> {
|
||||
removedAvatar = true
|
||||
return removeAvatarResult
|
||||
}
|
||||
|
||||
override suspend fun setName(name: String): Result<Unit> {
|
||||
newName = name
|
||||
return setNameResult
|
||||
}
|
||||
|
||||
override suspend fun setTopic(topic: String): Result<Unit> {
|
||||
newTopic = topic
|
||||
return setTopicResult
|
||||
}
|
||||
|
||||
override fun close() = Unit
|
||||
|
||||
fun givenLeaveRoomError(throwable: Throwable?) {
|
||||
|
|
@ -204,6 +247,10 @@ class FakeMatrixRoom(
|
|||
canInviteResult = result
|
||||
}
|
||||
|
||||
fun givenCanSendStateResult(type: StateEventType, result: Result<Boolean>) {
|
||||
canSendStateResults[type] = result
|
||||
}
|
||||
|
||||
fun givenIgnoreResult(result: Result<Unit>) {
|
||||
ignoreResult = result
|
||||
}
|
||||
|
|
@ -215,4 +262,20 @@ class FakeMatrixRoom(
|
|||
fun givenSendMediaResult(result: Result<Unit>) {
|
||||
sendMediaResult = result
|
||||
}
|
||||
|
||||
fun givenUpdateAvatarResult(result: Result<Unit>) {
|
||||
updateAvatarResult = result
|
||||
}
|
||||
|
||||
fun givenRemoveAvatarResult(result: Result<Unit>) {
|
||||
removeAvatarResult = result
|
||||
}
|
||||
|
||||
fun givenSetNameResult(result: Result<Unit>) {
|
||||
setNameResult = result
|
||||
}
|
||||
|
||||
fun givenSetTopicResult(result: Result<Unit>) {
|
||||
setTopicResult = result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue