Support update of order/autojoin of child
This commit is contained in:
parent
2cc5c76fb3
commit
5aa698768a
@ -26,5 +26,11 @@ interface Space {
|
|||||||
|
|
||||||
suspend fun removeRoom(roomId: String)
|
suspend fun removeRoom(roomId: String)
|
||||||
|
|
||||||
|
@Throws
|
||||||
|
suspend fun setChildrenOrder(roomId: String, order: String?)
|
||||||
|
|
||||||
|
@Throws
|
||||||
|
suspend fun setChildrenAutoJoin(roomId: String, autoJoin: Boolean)
|
||||||
|
|
||||||
// fun getChildren() : List<IRoomSummary>
|
// fun getChildren() : List<IRoomSummary>
|
||||||
}
|
}
|
||||||
|
@ -64,11 +64,6 @@ interface SpaceService {
|
|||||||
|
|
||||||
fun getSpaceSummaries(spaceSummaryQueryParams: SpaceSummaryQueryParams): List<SpaceSummary>
|
fun getSpaceSummaries(spaceSummaryQueryParams: SpaceSummaryQueryParams): List<SpaceSummary>
|
||||||
|
|
||||||
data class ChildAutoJoinInfo(
|
|
||||||
val roomIdOrAlias: String,
|
|
||||||
val viaServers: List<String> = emptyList()
|
|
||||||
)
|
|
||||||
|
|
||||||
sealed class JoinSpaceResult {
|
sealed class JoinSpaceResult {
|
||||||
object Success : JoinSpaceResult()
|
object Success : JoinSpaceResult()
|
||||||
data class Fail(val error: Throwable) : JoinSpaceResult()
|
data class Fail(val error: Throwable) : JoinSpaceResult()
|
||||||
|
@ -23,6 +23,7 @@ import org.matrix.android.sdk.api.session.events.model.toModel
|
|||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.space.Space
|
import org.matrix.android.sdk.api.session.space.Space
|
||||||
import org.matrix.android.sdk.api.session.space.model.SpaceChildContent
|
import org.matrix.android.sdk.api.session.space.model.SpaceChildContent
|
||||||
|
import java.lang.IllegalArgumentException
|
||||||
|
|
||||||
class DefaultSpace(private val room: Room) : Space {
|
class DefaultSpace(private val room: Room) : Space {
|
||||||
|
|
||||||
@ -61,11 +62,39 @@ class DefaultSpace(private val room: Room) : Space {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// override fun getChildren(): List<IRoomSummary> {
|
override suspend fun setChildrenOrder(roomId: String, order: String?) {
|
||||||
// // asRoom().getStateEvents(setOf(EventType.STATE_SPACE_CHILD)).mapNotNull {
|
val existing = asRoom().getStateEvents(setOf(EventType.STATE_SPACE_CHILD), QueryStringValue.Equals(roomId))
|
||||||
// // // statekeys are the roomIds
|
.firstOrNull()
|
||||||
// //
|
?.content.toModel<SpaceChildContent>()
|
||||||
// // }
|
?: throw IllegalArgumentException("$roomId is not a child of this space")
|
||||||
// return emptyList<IRoomSummary>()
|
|
||||||
// }
|
// edit state event and set via to null
|
||||||
|
asRoom().sendStateEvent(
|
||||||
|
eventType = EventType.STATE_SPACE_CHILD,
|
||||||
|
stateKey = roomId,
|
||||||
|
body = SpaceChildContent(
|
||||||
|
order = order,
|
||||||
|
via = existing.via,
|
||||||
|
autoJoin = existing.autoJoin
|
||||||
|
).toContent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun setChildrenAutoJoin(roomId: String, autoJoin: Boolean) {
|
||||||
|
val existing = asRoom().getStateEvents(setOf(EventType.STATE_SPACE_CHILD), QueryStringValue.Equals(roomId))
|
||||||
|
.firstOrNull()
|
||||||
|
?.content.toModel<SpaceChildContent>()
|
||||||
|
?: throw IllegalArgumentException("$roomId is not a child of this space")
|
||||||
|
|
||||||
|
// edit state event and set via to null
|
||||||
|
asRoom().sendStateEvent(
|
||||||
|
eventType = EventType.STATE_SPACE_CHILD,
|
||||||
|
stateKey = roomId,
|
||||||
|
body = SpaceChildContent(
|
||||||
|
order = existing.order,
|
||||||
|
via = existing.via,
|
||||||
|
autoJoin = autoJoin
|
||||||
|
).toContent()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3247,7 +3247,6 @@
|
|||||||
<string name="dev_tools_success_state_event">State event sent!</string>
|
<string name="dev_tools_success_state_event">State event sent!</string>
|
||||||
<string name="dev_tools_event_content_hint">Event content</string>
|
<string name="dev_tools_event_content_hint">Event content</string>
|
||||||
|
|
||||||
<string name="command_description_create_space">Create a community</string>
|
|
||||||
<string name="command_description_create_space">Create a Space</string>
|
<string name="command_description_create_space">Create a Space</string>
|
||||||
<string name="command_description_join_space">Join the Space with the given id</string>
|
<string name="command_description_join_space">Join the Space with the given id</string>
|
||||||
<string name="command_description_leave_room">Leave room with given id (or current room if null)</string>
|
<string name="command_description_leave_room">Leave room with given id (or current room if null)</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user