mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
Code review
This commit is contained in:
parent
872c45d5a3
commit
7d3d080603
37 changed files with 149 additions and 195 deletions
|
@ -74,13 +74,6 @@ class RxSession(private val session: Session) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun liveFlattenRoomSummaryChildOf(spaceId: String?): Observable<List<RoomSummary>> {
|
|
||||||
return session.getFlattenRoomSummaryChildrenOfLive(spaceId).asObservable()
|
|
||||||
.startWithCallable {
|
|
||||||
session.getFlattenRoomSummaryChildrenOf(spaceId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun liveBreadcrumbs(queryParams: RoomSummaryQueryParams): Observable<List<RoomSummary>> {
|
fun liveBreadcrumbs(queryParams: RoomSummaryQueryParams): Observable<List<RoomSummary>> {
|
||||||
return session.getBreadcrumbsLive(queryParams).asObservable()
|
return session.getBreadcrumbsLive(queryParams).asObservable()
|
||||||
.startWithCallable {
|
.startWithCallable {
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomPreset
|
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomPreset
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.RoomCreateContent
|
import org.matrix.android.sdk.api.session.room.model.create.RoomCreateContent
|
||||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||||
import org.matrix.android.sdk.api.session.space.SpaceService
|
import org.matrix.android.sdk.api.session.space.JoinSpaceResult
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.SessionTestParams
|
import org.matrix.android.sdk.common.SessionTestParams
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
@ -112,12 +112,12 @@ class SpaceCreationTest : InstrumentedTest {
|
||||||
|
|
||||||
// Try to join from bob, it's a public space no need to invite
|
// Try to join from bob, it's a public space no need to invite
|
||||||
|
|
||||||
val joinResult: SpaceService.JoinSpaceResult
|
val joinResult: JoinSpaceResult
|
||||||
runBlocking {
|
runBlocking {
|
||||||
joinResult = bobSession.spaceService().joinSpace(spaceId)
|
joinResult = bobSession.spaceService().joinSpace(spaceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(SpaceService.JoinSpaceResult.Success, joinResult)
|
assertEquals(JoinSpaceResult.Success, joinResult)
|
||||||
|
|
||||||
val spaceBobPov = bobSession.spaceService().getSpace(spaceId)
|
val spaceBobPov = bobSession.spaceService().getSpace(spaceId)
|
||||||
assertEquals(roomName, spaceBobPov?.asRoom()?.roomSummary()?.name, "Room name should be set")
|
assertEquals(roomName, spaceBobPov?.asRoom()?.roomSummary()?.name, "Room name should be set")
|
||||||
|
@ -169,7 +169,7 @@ class SpaceCreationTest : InstrumentedTest {
|
||||||
bobSession.spaceService().joinSpace(spaceId)
|
bobSession.spaceService().joinSpace(spaceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(SpaceService.JoinSpaceResult.Success, joinResult)
|
assertEquals(JoinSpaceResult.Success, joinResult)
|
||||||
|
|
||||||
val spaceBobPov = bobSession.spaceService().getSpace(spaceId)
|
val spaceBobPov = bobSession.spaceService().getSpace(spaceId)
|
||||||
assertEquals(roomName, spaceBobPov?.asRoom()?.roomSummary()?.name, "Room name should be set")
|
assertEquals(roomName, spaceBobPov?.asRoom()?.roomSummary()?.name, "Room name should be set")
|
||||||
|
@ -186,7 +186,7 @@ class SpaceCreationTest : InstrumentedTest {
|
||||||
this.memberships = listOf(Membership.JOIN)
|
this.memberships = listOf(Membership.JOIN)
|
||||||
}).firstOrNull()
|
}).firstOrNull()
|
||||||
|
|
||||||
assertEquals(2, spaceSummaryBobPov?.children?.size ?: -1, "Unexpected number of children")
|
assertEquals(2, spaceSummaryBobPov?.spaceChildren?.size ?: -1, "Unexpected number of children")
|
||||||
|
|
||||||
commonTestHelper.signOutAndClose(aliceSession)
|
commonTestHelper.signOutAndClose(aliceSession)
|
||||||
commonTestHelper.signOutAndClose(bobSession)
|
commonTestHelper.signOutAndClose(bobSession)
|
||||||
|
|
|
@ -31,7 +31,7 @@ data class RoomJoinRulesContent(
|
||||||
/**
|
/**
|
||||||
* If the allow key is an empty list (or not a list at all), then the room reverts to standard public join rules
|
* If the allow key is an empty list (or not a list at all), then the room reverts to standard public join rules
|
||||||
*/
|
*/
|
||||||
@Json(name = "allow") val allowList:List<RoomJoinRulesAllowEntry>? = null
|
@Json(name = "allow") val allowList: List<RoomJoinRulesAllowEntry>? = null
|
||||||
) {
|
) {
|
||||||
val joinRules: RoomJoinRules? = when (_joinRules) {
|
val joinRules: RoomJoinRules? = when (_joinRules) {
|
||||||
"public" -> RoomJoinRules.PUBLIC
|
"public" -> RoomJoinRules.PUBLIC
|
||||||
|
|
|
@ -57,7 +57,7 @@ data class RoomSummary constructor(
|
||||||
val hasFailedSending: Boolean = false,
|
val hasFailedSending: Boolean = false,
|
||||||
val roomType: String? = null,
|
val roomType: String? = null,
|
||||||
val spaceParents: List<SpaceParentInfo>? = null,
|
val spaceParents: List<SpaceParentInfo>? = null,
|
||||||
val children: List<SpaceChildInfo>? = null,
|
val spaceChildren: List<SpaceChildInfo>? = null,
|
||||||
val flattenParentIds: List<String> = emptyList()
|
val flattenParentIds: List<String> = emptyList()
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.matrix.android.sdk.api.session.space
|
||||||
|
|
||||||
|
sealed class JoinSpaceResult {
|
||||||
|
object Success : JoinSpaceResult()
|
||||||
|
data class Fail(val error: Throwable) : JoinSpaceResult()
|
||||||
|
|
||||||
|
/** Success fully joined the space, but failed to join all or some of it's rooms */
|
||||||
|
data class PartialSuccess(val failedRooms: Map<String, Throwable>) : JoinSpaceResult()
|
||||||
|
|
||||||
|
fun isSuccess() = this is Success || this is PartialSuccess
|
||||||
|
}
|
|
@ -67,16 +67,6 @@ interface SpaceService {
|
||||||
|
|
||||||
fun getSpaceSummaries(spaceSummaryQueryParams: SpaceSummaryQueryParams): List<RoomSummary>
|
fun getSpaceSummaries(spaceSummaryQueryParams: SpaceSummaryQueryParams): List<RoomSummary>
|
||||||
|
|
||||||
sealed class JoinSpaceResult {
|
|
||||||
object Success : JoinSpaceResult()
|
|
||||||
data class Fail(val error: Throwable) : JoinSpaceResult()
|
|
||||||
|
|
||||||
/** Success fully joined the space, but failed to join all or some of it's rooms */
|
|
||||||
data class PartialSuccess(val failedRooms: Map<String, Throwable>) : JoinSpaceResult()
|
|
||||||
|
|
||||||
fun isSuccess() = this is Success || this is PartialSuccess
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun joinSpace(spaceIdOrAlias: String,
|
suspend fun joinSpace(spaceIdOrAlias: String,
|
||||||
reason: String? = null,
|
reason: String? = null,
|
||||||
viaServers: List<String> = emptyList()): JoinSpaceResult
|
viaServers: List<String> = emptyList()): JoinSpaceResult
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.matrix.android.sdk.BuildConfig
|
||||||
import org.matrix.android.sdk.api.session.group.model.GroupSummary
|
import org.matrix.android.sdk.api.session.group.model.GroupSummary
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
|
import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
|
||||||
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom
|
import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom
|
||||||
import org.matrix.android.sdk.api.session.room.sender.SenderInfo
|
import org.matrix.android.sdk.api.session.room.sender.SenderInfo
|
||||||
import org.matrix.android.sdk.api.session.user.model.User
|
import org.matrix.android.sdk.api.session.user.model.User
|
||||||
|
@ -86,9 +87,9 @@ sealed class MatrixItem(
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun checkId() {
|
protected fun checkId() {
|
||||||
// if (!id.startsWith(getIdPrefix())) {
|
if (!id.startsWith(getIdPrefix())) {
|
||||||
// error("Wrong usage of MatrixItem: check the id $id should start with ${getIdPrefix()}")
|
error("Wrong usage of MatrixItem: check the id $id should start with ${getIdPrefix()}")
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,3 +158,5 @@ fun PublicRoom.toMatrixItem() = MatrixItem.RoomItem(roomId, name ?: getPrimaryAl
|
||||||
fun RoomMemberSummary.toMatrixItem() = MatrixItem.UserItem(userId, displayName, avatarUrl)
|
fun RoomMemberSummary.toMatrixItem() = MatrixItem.UserItem(userId, displayName, avatarUrl)
|
||||||
|
|
||||||
fun SenderInfo.toMatrixItem() = MatrixItem.UserItem(userId, disambiguatedDisplayName, avatarUrl)
|
fun SenderInfo.toMatrixItem() = MatrixItem.UserItem(userId, disambiguatedDisplayName, avatarUrl)
|
||||||
|
|
||||||
|
fun SpaceChildInfo.toMatrixItem() = MatrixItem.RoomItem(childRoomId, name, avatarUrl)
|
||||||
|
|
|
@ -72,8 +72,7 @@ internal class SessionRealmConfigurationFactory @Inject constructor(
|
||||||
.allowWritesOnUiThread(true)
|
.allowWritesOnUiThread(true)
|
||||||
.modules(SessionRealmModule())
|
.modules(SessionRealmModule())
|
||||||
.schemaVersion(RealmSessionStoreMigration.SESSION_STORE_SCHEMA_VERSION)
|
.schemaVersion(RealmSessionStoreMigration.SESSION_STORE_SCHEMA_VERSION)
|
||||||
.deleteRealmIfMigrationNeeded()
|
.migration(migration)
|
||||||
// .migration(migration)
|
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
// Try creating a realm instance and if it succeeds we can clear the flag
|
// Try creating a realm instance and if it succeeds we can clear the flag
|
||||||
|
|
|
@ -75,7 +75,7 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa
|
||||||
viaServers = relationInfoEntity.viaServers.toList()
|
viaServers = relationInfoEntity.viaServers.toList()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
children = roomSummaryEntity.children.map {
|
spaceChildren = roomSummaryEntity.children.map {
|
||||||
SpaceChildInfo(
|
SpaceChildInfo(
|
||||||
childRoomId = it.childRoomId ?: "",
|
childRoomId = it.childRoomId ?: "",
|
||||||
isKnown = it.childSummaryEntity != null,
|
isKnown = it.childSummaryEntity != null,
|
||||||
|
|
|
@ -25,12 +25,12 @@ import timber.log.Timber
|
||||||
fun <T : RealmObject> RealmQuery<T>.process(field: String, queryStringValue: QueryStringValue): RealmQuery<T> {
|
fun <T : RealmObject> RealmQuery<T>.process(field: String, queryStringValue: QueryStringValue): RealmQuery<T> {
|
||||||
when (queryStringValue) {
|
when (queryStringValue) {
|
||||||
is QueryStringValue.NoCondition -> Timber.v("No condition to process")
|
is QueryStringValue.NoCondition -> Timber.v("No condition to process")
|
||||||
is QueryStringValue.IsNotNull -> isNotNull(field)
|
is QueryStringValue.IsNotNull -> isNotNull(field)
|
||||||
is QueryStringValue.IsNull -> isNull(field)
|
is QueryStringValue.IsNull -> isNull(field)
|
||||||
is QueryStringValue.IsEmpty -> isEmpty(field)
|
is QueryStringValue.IsEmpty -> isEmpty(field)
|
||||||
is QueryStringValue.IsNotEmpty -> isNotEmpty(field)
|
is QueryStringValue.IsNotEmpty -> isNotEmpty(field)
|
||||||
is QueryStringValue.Equals -> equalTo(field, queryStringValue.string, queryStringValue.case.toRealmCase())
|
is QueryStringValue.Equals -> equalTo(field, queryStringValue.string, queryStringValue.case.toRealmCase())
|
||||||
is QueryStringValue.Contains -> contains(field, queryStringValue.string, queryStringValue.case.toRealmCase())
|
is QueryStringValue.Contains -> contains(field, queryStringValue.string, queryStringValue.case.toRealmCase())
|
||||||
}
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,6 @@ fun <T : RealmObject> RealmQuery<T>.process(field: String, queryStringValue: Que
|
||||||
private fun QueryStringValue.Case.toRealmCase(): Case {
|
private fun QueryStringValue.Case.toRealmCase(): Case {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
QueryStringValue.Case.INSENSITIVE -> Case.INSENSITIVE
|
QueryStringValue.Case.INSENSITIVE -> Case.INSENSITIVE
|
||||||
QueryStringValue.Case.SENSITIVE -> Case.SENSITIVE
|
QueryStringValue.Case.SENSITIVE -> Case.SENSITIVE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
||||||
import org.matrix.android.sdk.api.session.identity.toMedium
|
import org.matrix.android.sdk.api.session.identity.toMedium
|
||||||
import org.matrix.android.sdk.api.session.room.model.GuestAccess
|
import org.matrix.android.sdk.api.session.room.model.GuestAccess
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomGuestAccessContent
|
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility
|
import org.matrix.android.sdk.api.session.room.model.RoomHistoryVisibility
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
|
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesContent
|
import org.matrix.android.sdk.api.session.room.model.RoomJoinRulesContent
|
||||||
|
@ -144,7 +143,7 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
||||||
Event(
|
Event(
|
||||||
type = EventType.STATE_ROOM_GUEST_ACCESS,
|
type = EventType.STATE_ROOM_GUEST_ACCESS,
|
||||||
stateKey = "",
|
stateKey = "",
|
||||||
content = RoomGuestAccessContent(it.value).toContent()
|
content = mapOf("guest_access" to it.value)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,7 +349,7 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
|
|
||||||
// it may not have a parent relation but could be a child of some other....
|
// it may not have a parent relation but could be a child of some other....
|
||||||
for (spaceSummary in getSpaceSummaries(spaceSummaryQueryParams { memberships = Membership.activeMemberships() })) {
|
for (spaceSummary in getSpaceSummaries(spaceSummaryQueryParams { memberships = Membership.activeMemberships() })) {
|
||||||
if (spaceSummary.children?.any { it.childRoomId == roomSummary.roomId } == true) {
|
if (spaceSummary.spaceChildren?.any { it.childRoomId == roomSummary.roomId } == true) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,7 +358,7 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
}
|
}
|
||||||
|
|
||||||
fun flattenChild(current: RoomSummary, parenting: List<String>, output: MutableList<RoomSummary>, memberShips: List<Membership>) {
|
fun flattenChild(current: RoomSummary, parenting: List<String>, output: MutableList<RoomSummary>, memberShips: List<Membership>) {
|
||||||
current.children?.sortedBy { it.order ?: it.name }?.forEach { childInfo ->
|
current.spaceChildren?.sortedBy { it.order ?: it.name }?.forEach { childInfo ->
|
||||||
if (childInfo.roomType == RoomType.SPACE) {
|
if (childInfo.roomType == RoomType.SPACE) {
|
||||||
// Add recursive
|
// Add recursive
|
||||||
if (!parenting.contains(childInfo.childRoomId)) { // avoid cycles!
|
if (!parenting.contains(childInfo.childRoomId)) { // avoid cycles!
|
||||||
|
@ -388,7 +388,7 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
if (includeCurrent) {
|
if (includeCurrent) {
|
||||||
output.add(current)
|
output.add(current)
|
||||||
}
|
}
|
||||||
current.children?.sortedBy { it.order ?: it.name }?.forEach {
|
current.spaceChildren?.sortedBy { it.order ?: it.name }?.forEach {
|
||||||
if (it.roomType == RoomType.SPACE) {
|
if (it.roomType == RoomType.SPACE) {
|
||||||
// Add recursive
|
// Add recursive
|
||||||
if (!parenting.contains(it.childRoomId)) { // avoid cycles!
|
if (!parenting.contains(it.childRoomId)) { // avoid cycles!
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2021 The Matrix.org Foundation C.I.C.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.session.space
|
|
||||||
|
|
||||||
import io.realm.RealmConfiguration
|
|
||||||
import kotlinx.coroutines.TimeoutCancellationException
|
|
||||||
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
|
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
|
||||||
import org.matrix.android.sdk.internal.database.awaitNotEmptyResult
|
|
||||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
|
||||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
|
|
||||||
import org.matrix.android.sdk.internal.di.SessionDatabase
|
|
||||||
import org.matrix.android.sdk.internal.session.room.create.CreateRoomTask
|
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple wrapper of create room task that adds waiting for DB entities of spaces
|
|
||||||
*/
|
|
||||||
internal interface CreateSpaceTask : Task<CreateRoomParams, String>
|
|
||||||
|
|
||||||
internal class DefaultCreateSpaceTask @Inject constructor(
|
|
||||||
private val createRoomTask: CreateRoomTask,
|
|
||||||
@SessionDatabase private val realmConfiguration: RealmConfiguration
|
|
||||||
) : CreateSpaceTask {
|
|
||||||
|
|
||||||
override suspend fun execute(params: CreateRoomParams): String {
|
|
||||||
val spaceId = createRoomTask.execute(params)
|
|
||||||
|
|
||||||
try {
|
|
||||||
awaitNotEmptyResult(realmConfiguration, TimeUnit.MINUTES.toMillis(1L)) { realm ->
|
|
||||||
realm.where(RoomSummaryEntity::class.java)
|
|
||||||
.equalTo(RoomSummaryEntityFields.ROOM_ID, spaceId)
|
|
||||||
}
|
|
||||||
} catch (exception: TimeoutCancellationException) {
|
|
||||||
throw CreateRoomFailure.CreatedWithTimeout(spaceId)
|
|
||||||
}
|
|
||||||
|
|
||||||
return spaceId
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -32,6 +32,7 @@ import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomPreset
|
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomPreset
|
||||||
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
||||||
import org.matrix.android.sdk.api.session.space.CreateSpaceParams
|
import org.matrix.android.sdk.api.session.space.CreateSpaceParams
|
||||||
|
import org.matrix.android.sdk.api.session.space.JoinSpaceResult
|
||||||
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.SpaceService
|
import org.matrix.android.sdk.api.session.space.SpaceService
|
||||||
import org.matrix.android.sdk.api.session.space.SpaceSummaryQueryParams
|
import org.matrix.android.sdk.api.session.space.SpaceSummaryQueryParams
|
||||||
|
@ -40,6 +41,7 @@ import org.matrix.android.sdk.api.session.space.model.SpaceParentContent
|
||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.session.room.RoomGetter
|
import org.matrix.android.sdk.internal.session.room.RoomGetter
|
||||||
import org.matrix.android.sdk.internal.session.room.SpaceGetter
|
import org.matrix.android.sdk.internal.session.room.SpaceGetter
|
||||||
|
import org.matrix.android.sdk.internal.session.room.create.CreateRoomTask
|
||||||
import org.matrix.android.sdk.internal.session.room.membership.leaving.LeaveRoomTask
|
import org.matrix.android.sdk.internal.session.room.membership.leaving.LeaveRoomTask
|
||||||
import org.matrix.android.sdk.internal.session.room.state.StateEventDataSource
|
import org.matrix.android.sdk.internal.session.room.state.StateEventDataSource
|
||||||
import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryDataSource
|
import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryDataSource
|
||||||
|
@ -49,7 +51,7 @@ import javax.inject.Inject
|
||||||
|
|
||||||
internal class DefaultSpaceService @Inject constructor(
|
internal class DefaultSpaceService @Inject constructor(
|
||||||
@UserId private val userId: String,
|
@UserId private val userId: String,
|
||||||
private val createSpaceTask: CreateSpaceTask,
|
private val createRoomTask: CreateRoomTask,
|
||||||
private val joinSpaceTask: JoinSpaceTask,
|
private val joinSpaceTask: JoinSpaceTask,
|
||||||
private val spaceGetter: SpaceGetter,
|
private val spaceGetter: SpaceGetter,
|
||||||
private val roomGetter: RoomGetter,
|
private val roomGetter: RoomGetter,
|
||||||
|
@ -61,7 +63,7 @@ internal class DefaultSpaceService @Inject constructor(
|
||||||
) : SpaceService {
|
) : SpaceService {
|
||||||
|
|
||||||
override suspend fun createSpace(params: CreateSpaceParams): String {
|
override suspend fun createSpace(params: CreateSpaceParams): String {
|
||||||
return createSpaceTask.executeRetry(params, 3)
|
return createRoomTask.executeRetry(params, 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun createSpace(name: String, topic: String?, avatarUri: Uri?, isPublic: Boolean): String {
|
override suspend fun createSpace(name: String, topic: String?, avatarUri: Uri?, isPublic: Boolean): String {
|
||||||
|
@ -149,7 +151,7 @@ internal class DefaultSpaceService @Inject constructor(
|
||||||
|
|
||||||
override suspend fun joinSpace(spaceIdOrAlias: String,
|
override suspend fun joinSpace(spaceIdOrAlias: String,
|
||||||
reason: String?,
|
reason: String?,
|
||||||
viaServers: List<String>): SpaceService.JoinSpaceResult {
|
viaServers: List<String>): JoinSpaceResult {
|
||||||
return joinSpaceTask.execute(JoinSpaceTask.Params(spaceIdOrAlias, reason, viaServers))
|
return joinSpaceTask.execute(JoinSpaceTask.Params(spaceIdOrAlias, reason, viaServers))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import io.realm.RealmConfiguration
|
||||||
import kotlinx.coroutines.TimeoutCancellationException
|
import kotlinx.coroutines.TimeoutCancellationException
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomType
|
import org.matrix.android.sdk.api.session.room.model.RoomType
|
||||||
import org.matrix.android.sdk.api.session.space.SpaceService
|
import org.matrix.android.sdk.api.session.space.JoinSpaceResult
|
||||||
import org.matrix.android.sdk.internal.database.awaitNotEmptyResult
|
import org.matrix.android.sdk.internal.database.awaitNotEmptyResult
|
||||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntity
|
||||||
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
|
import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields
|
||||||
|
@ -32,7 +32,7 @@ import timber.log.Timber
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface JoinSpaceTask : Task<JoinSpaceTask.Params, SpaceService.JoinSpaceResult> {
|
internal interface JoinSpaceTask : Task<JoinSpaceTask.Params, JoinSpaceResult> {
|
||||||
data class Params(
|
data class Params(
|
||||||
val roomIdOrAlias: String,
|
val roomIdOrAlias: String,
|
||||||
val reason: String?,
|
val reason: String?,
|
||||||
|
@ -47,7 +47,7 @@ internal class DefaultJoinSpaceTask @Inject constructor(
|
||||||
private val roomSummaryDataSource: RoomSummaryDataSource
|
private val roomSummaryDataSource: RoomSummaryDataSource
|
||||||
) : JoinSpaceTask {
|
) : JoinSpaceTask {
|
||||||
|
|
||||||
override suspend fun execute(params: JoinSpaceTask.Params): SpaceService.JoinSpaceResult {
|
override suspend fun execute(params: JoinSpaceTask.Params): JoinSpaceResult {
|
||||||
Timber.v("## Space: > Joining root space ${params.roomIdOrAlias} ...")
|
Timber.v("## Space: > Joining root space ${params.roomIdOrAlias} ...")
|
||||||
try {
|
try {
|
||||||
joinRoomTask.execute(JoinRoomTask.Params(
|
joinRoomTask.execute(JoinRoomTask.Params(
|
||||||
|
@ -56,7 +56,7 @@ internal class DefaultJoinSpaceTask @Inject constructor(
|
||||||
params.viaServers
|
params.viaServers
|
||||||
))
|
))
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
return SpaceService.JoinSpaceResult.Fail(failure)
|
return JoinSpaceResult.Fail(failure)
|
||||||
}
|
}
|
||||||
Timber.v("## Space: < Joining root space done for ${params.roomIdOrAlias}")
|
Timber.v("## Space: < Joining root space done for ${params.roomIdOrAlias}")
|
||||||
// we want to wait for sync result to check for auto join rooms
|
// we want to wait for sync result to check for auto join rooms
|
||||||
|
@ -76,15 +76,15 @@ internal class DefaultJoinSpaceTask @Inject constructor(
|
||||||
}
|
}
|
||||||
} catch (exception: TimeoutCancellationException) {
|
} catch (exception: TimeoutCancellationException) {
|
||||||
Timber.w("## Space: > Error created with timeout")
|
Timber.w("## Space: > Error created with timeout")
|
||||||
return SpaceService.JoinSpaceResult.PartialSuccess(emptyMap())
|
return JoinSpaceResult.PartialSuccess(emptyMap())
|
||||||
}
|
}
|
||||||
|
|
||||||
val errors = mutableMapOf<String, Throwable>()
|
val errors = mutableMapOf<String, Throwable>()
|
||||||
Timber.v("## Space: > Sync done ...")
|
Timber.v("## Space: > Sync done ...")
|
||||||
// after that i should have the children (? do I need to paginate to get state)
|
// after that i should have the children (? do I need to paginate to get state)
|
||||||
val summary = roomSummaryDataSource.getSpaceSummary(params.roomIdOrAlias)
|
val summary = roomSummaryDataSource.getSpaceSummary(params.roomIdOrAlias)
|
||||||
Timber.v("## Space: Found space summary Name:[${summary?.name}] children: ${summary?.children?.size}")
|
Timber.v("## Space: Found space summary Name:[${summary?.name}] children: ${summary?.spaceChildren?.size}")
|
||||||
summary?.children?.forEach {
|
summary?.spaceChildren?.forEach {
|
||||||
// val childRoomSummary = it.roomSummary ?: return@forEach
|
// val childRoomSummary = it.roomSummary ?: return@forEach
|
||||||
Timber.v("## Space: Processing child :[${it.childRoomId}] autoJoin:${it.autoJoin}")
|
Timber.v("## Space: Processing child :[${it.childRoomId}] autoJoin:${it.autoJoin}")
|
||||||
if (it.autoJoin) {
|
if (it.autoJoin) {
|
||||||
|
@ -92,13 +92,13 @@ internal class DefaultJoinSpaceTask @Inject constructor(
|
||||||
if (it.roomType == RoomType.SPACE) {
|
if (it.roomType == RoomType.SPACE) {
|
||||||
// recursively join auto-joined child of this space?
|
// recursively join auto-joined child of this space?
|
||||||
when (val subspaceJoinResult = execute(JoinSpaceTask.Params(it.childRoomId, null, it.viaServers))) {
|
when (val subspaceJoinResult = execute(JoinSpaceTask.Params(it.childRoomId, null, it.viaServers))) {
|
||||||
SpaceService.JoinSpaceResult.Success -> {
|
JoinSpaceResult.Success -> {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
is SpaceService.JoinSpaceResult.Fail -> {
|
is JoinSpaceResult.Fail -> {
|
||||||
errors[it.childRoomId] = subspaceJoinResult.error
|
errors[it.childRoomId] = subspaceJoinResult.error
|
||||||
}
|
}
|
||||||
is SpaceService.JoinSpaceResult.PartialSuccess -> {
|
is JoinSpaceResult.PartialSuccess -> {
|
||||||
errors.putAll(subspaceJoinResult.failedRooms)
|
errors.putAll(subspaceJoinResult.failedRooms)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,9 @@ internal class DefaultJoinSpaceTask @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (errors.isEmpty()) {
|
return if (errors.isEmpty()) {
|
||||||
SpaceService.JoinSpaceResult.Success
|
JoinSpaceResult.Success
|
||||||
} else {
|
} else {
|
||||||
SpaceService.JoinSpaceResult.PartialSuccess(errors)
|
JoinSpaceResult.PartialSuccess(errors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,6 @@ internal abstract class SpaceModule {
|
||||||
@Binds
|
@Binds
|
||||||
abstract fun bindJoinSpaceTask(task: DefaultJoinSpaceTask): JoinSpaceTask
|
abstract fun bindJoinSpaceTask(task: DefaultJoinSpaceTask): JoinSpaceTask
|
||||||
|
|
||||||
@Binds
|
|
||||||
abstract fun bindCreateSpaceTask(task: DefaultCreateSpaceTask): CreateSpaceTask
|
|
||||||
|
|
||||||
@Binds
|
@Binds
|
||||||
abstract fun bindSpaceGetter(getter: DefaultSpaceGetter): SpaceGetter
|
abstract fun bindSpaceGetter(getter: DefaultSpaceGetter): SpaceGetter
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,11 @@ open class BottomSheetGenericRadioAction(
|
||||||
) : VectorSharedAction {
|
) : VectorSharedAction {
|
||||||
|
|
||||||
fun toRadioBottomSheetItem(): BottomSheetRadioActionItem_ {
|
fun toRadioBottomSheetItem(): BottomSheetRadioActionItem_ {
|
||||||
return BottomSheetRadioActionItem_().apply {
|
return BottomSheetRadioActionItem_().also {
|
||||||
id("action_${this@BottomSheetGenericRadioAction.title}")
|
it.id("action_$title")
|
||||||
title(this@BottomSheetGenericRadioAction.title)
|
it.title(title)
|
||||||
selected(this@BottomSheetGenericRadioAction.isSelected)
|
it.selected(isSelected)
|
||||||
description(this@BottomSheetGenericRadioAction.description)
|
it.description(description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import im.vector.app.core.platform.EmptyAction
|
||||||
import im.vector.app.core.platform.EmptyViewEvents
|
import im.vector.app.core.platform.EmptyViewEvents
|
||||||
import im.vector.app.core.platform.VectorViewModel
|
import im.vector.app.core.platform.VectorViewModel
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.functions.BiFunction
|
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import org.matrix.android.sdk.api.query.ActiveSpaceFilter
|
import org.matrix.android.sdk.api.query.ActiveSpaceFilter
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
@ -66,8 +65,8 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
override fun create(viewModelContext: ViewModelContext, state: UnreadMessagesState): UnreadMessagesSharedViewModel? {
|
override fun create(viewModelContext: ViewModelContext, state: UnreadMessagesState): UnreadMessagesSharedViewModel? {
|
||||||
val factory = when (viewModelContext) {
|
val factory = when (viewModelContext) {
|
||||||
is FragmentViewModelContext -> viewModelContext.fragment as? UnreadMessagesSharedViewModel.Factory
|
is FragmentViewModelContext -> viewModelContext.fragment as? Factory
|
||||||
is ActivityViewModelContext -> viewModelContext.activity as? UnreadMessagesSharedViewModel.Factory
|
is ActivityViewModelContext -> viewModelContext.activity as? Factory
|
||||||
}
|
}
|
||||||
return factory?.create(state) ?: error("You should let your activity/fragment implements Factory interface")
|
return factory?.create(state) ?: error("You should let your activity/fragment implements Factory interface")
|
||||||
}
|
}
|
||||||
|
@ -84,7 +83,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
||||||
}, sortOrder = RoomSortOrder.NONE
|
}, sortOrder = RoomSortOrder.NONE
|
||||||
).asObservable()
|
).asObservable()
|
||||||
.throttleFirst(300, TimeUnit.MILLISECONDS)
|
.throttleFirst(300, TimeUnit.MILLISECONDS)
|
||||||
.subscribe {
|
.execute {
|
||||||
val counts = session.getNotificationCountForRooms(
|
val counts = session.getNotificationCountForRooms(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
this.memberships = listOf(Membership.JOIN)
|
this.memberships = listOf(Membership.JOIN)
|
||||||
|
@ -97,15 +96,13 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
||||||
this.activeSpaceId = ActiveSpaceFilter.ActiveSpace(null)
|
this.activeSpaceId = ActiveSpaceFilter.ActiveSpace(null)
|
||||||
}
|
}
|
||||||
).size
|
).size
|
||||||
setState {
|
copy(
|
||||||
copy(
|
homeSpaceUnread = RoomAggregateNotificationCount(
|
||||||
homeSpaceUnread = RoomAggregateNotificationCount(
|
counts.notificationCount + invites,
|
||||||
counts.notificationCount + invites,
|
highlightCount = counts.highlightCount + invites
|
||||||
highlightCount = counts.highlightCount + invites
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
|
||||||
}.disposeOnClear()
|
|
||||||
|
|
||||||
Observable.combineLatest(
|
Observable.combineLatest(
|
||||||
appStateHandler.selectedRoomGroupingObservable.distinctUntilChanged(),
|
appStateHandler.selectedRoomGroupingObservable.distinctUntilChanged(),
|
||||||
|
@ -118,7 +115,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
||||||
.throttleFirst(300, TimeUnit.MILLISECONDS)
|
.throttleFirst(300, TimeUnit.MILLISECONDS)
|
||||||
.observeOn(Schedulers.computation())
|
.observeOn(Schedulers.computation())
|
||||||
},
|
},
|
||||||
BiFunction { groupingMethod, _ ->
|
{ groupingMethod, _ ->
|
||||||
when (groupingMethod.orNull()) {
|
when (groupingMethod.orNull()) {
|
||||||
is RoomGroupingMethod.ByLegacyGroup -> {
|
is RoomGroupingMethod.ByLegacyGroup -> {
|
||||||
// currently not supported
|
// currently not supported
|
||||||
|
|
|
@ -644,6 +644,9 @@ class RoomDetailFragment @Inject constructor(
|
||||||
private fun handleSpaceShare() {
|
private fun handleSpaceShare() {
|
||||||
roomDetailArgs.openShareSpaceForId?.let { spaceId ->
|
roomDetailArgs.openShareSpaceForId?.let { spaceId ->
|
||||||
ShareSpaceBottomSheet.show(childFragmentManager, spaceId)
|
ShareSpaceBottomSheet.show(childFragmentManager, spaceId)
|
||||||
|
view?.post {
|
||||||
|
handleChatEffect(ChatEffect.CONFETTI)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,8 @@ class RoomListFragment @Inject constructor(
|
||||||
|
|
||||||
data class SectionAdapterInfo(
|
data class SectionAdapterInfo(
|
||||||
var section: SectionKey,
|
var section: SectionKey,
|
||||||
val headerHeaderAdapter: SectionHeaderAdapter,
|
val sectionHeaderAdapter: SectionHeaderAdapter,
|
||||||
val contentAdapter: EpoxyController
|
val contentEpoxyController: EpoxyController
|
||||||
)
|
)
|
||||||
|
|
||||||
private val adapterInfosList = mutableListOf<SectionAdapterInfo>()
|
private val adapterInfosList = mutableListOf<SectionAdapterInfo>()
|
||||||
|
@ -126,7 +126,7 @@ class RoomListFragment @Inject constructor(
|
||||||
// it's for invites local echo
|
// it's for invites local echo
|
||||||
adapterInfosList.filter { it.section.notifyOfLocalEcho }
|
adapterInfosList.filter { it.section.notifyOfLocalEcho }
|
||||||
.onEach {
|
.onEach {
|
||||||
(it.contentAdapter as? RoomSummaryPagedController)?.roomChangeMembershipStates = ms
|
(it.contentEpoxyController as? RoomSummaryPagedController)?.roomChangeMembershipStates = ms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,16 +137,16 @@ class RoomListFragment @Inject constructor(
|
||||||
val isRoomSectionExpanded = roomsSection.isExpanded.value.orTrue()
|
val isRoomSectionExpanded = roomsSection.isExpanded.value.orTrue()
|
||||||
if (actualBlock.section.isExpanded && !isRoomSectionExpanded) {
|
if (actualBlock.section.isExpanded && !isRoomSectionExpanded) {
|
||||||
// mark controller as collapsed
|
// mark controller as collapsed
|
||||||
actualBlock.contentAdapter.setCollapsed(true)
|
actualBlock.contentEpoxyController.setCollapsed(true)
|
||||||
} else if (!actualBlock.section.isExpanded && isRoomSectionExpanded) {
|
} else if (!actualBlock.section.isExpanded && isRoomSectionExpanded) {
|
||||||
// we must expand!
|
// we must expand!
|
||||||
actualBlock.contentAdapter.setCollapsed(false)
|
actualBlock.contentEpoxyController.setCollapsed(false)
|
||||||
}
|
}
|
||||||
actualBlock.section = actualBlock.section.copy(
|
actualBlock.section = actualBlock.section.copy(
|
||||||
isExpanded = isRoomSectionExpanded
|
isExpanded = isRoomSectionExpanded
|
||||||
)
|
)
|
||||||
actualBlock.headerHeaderAdapter.updateSection(
|
actualBlock.sectionHeaderAdapter.updateSection(
|
||||||
actualBlock.headerHeaderAdapter.roomsSectionData.copy(isExpanded = isRoomSectionExpanded)
|
actualBlock.sectionHeaderAdapter.roomsSectionData.copy(isExpanded = isRoomSectionExpanded)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ class RoomListFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
adapterInfosList.onEach { it.contentAdapter.removeModelBuildListener(modelBuildListener) }
|
adapterInfosList.onEach { it.contentEpoxyController.removeModelBuildListener(modelBuildListener) }
|
||||||
adapterInfosList.clear()
|
adapterInfosList.clear()
|
||||||
modelBuildListener = null
|
modelBuildListener = null
|
||||||
views.roomListView.cleanup()
|
views.roomListView.cleanup()
|
||||||
|
@ -401,8 +401,8 @@ class RoomListFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkEmptyState() {
|
private fun checkEmptyState() {
|
||||||
val shouldShowEmpty = adapterInfosList.all { it.headerHeaderAdapter.roomsSectionData.isHidden }
|
val shouldShowEmpty = adapterInfosList.all { it.sectionHeaderAdapter.roomsSectionData.isHidden }
|
||||||
&& !adapterInfosList.any { it.headerHeaderAdapter.roomsSectionData.isLoading }
|
&& !adapterInfosList.any { it.sectionHeaderAdapter.roomsSectionData.isLoading }
|
||||||
if (shouldShowEmpty) {
|
if (shouldShowEmpty) {
|
||||||
val emptyState = when (roomListParams.displayMode) {
|
val emptyState = when (roomListParams.displayMode) {
|
||||||
RoomListDisplayMode.NOTIFICATIONS -> {
|
RoomListDisplayMode.NOTIFICATIONS -> {
|
||||||
|
@ -432,7 +432,7 @@ class RoomListFragment @Inject constructor(
|
||||||
views.stateView.state = emptyState
|
views.stateView.state = emptyState
|
||||||
} else {
|
} else {
|
||||||
// is there something to show already?
|
// is there something to show already?
|
||||||
if (adapterInfosList.any { !it.headerHeaderAdapter.roomsSectionData.isHidden }) {
|
if (adapterInfosList.any { !it.sectionHeaderAdapter.roomsSectionData.isHidden }) {
|
||||||
views.stateView.state = StateView.State.Content
|
views.stateView.state = StateView.State.Content
|
||||||
} else {
|
} else {
|
||||||
views.stateView.state = StateView.State.Loading
|
views.stateView.state = StateView.State.Loading
|
||||||
|
|
|
@ -65,8 +65,17 @@ class RoomListViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class SpaceFilterStrategy {
|
enum class SpaceFilterStrategy {
|
||||||
|
/**
|
||||||
|
* Filter the rooms if they are part of the current space (children and grand children).
|
||||||
|
* If current space is null, will return orphan rooms only
|
||||||
|
*/
|
||||||
NORMAL,
|
NORMAL,
|
||||||
|
/**
|
||||||
|
* Special case when we don't want to discriminate rooms when current space is null.
|
||||||
|
* In this case return all.
|
||||||
|
*/
|
||||||
NOT_IF_ALL,
|
NOT_IF_ALL,
|
||||||
|
/** Do not filter based on space*/
|
||||||
NONE
|
NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
|
import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
|
||||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -60,7 +59,7 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
||||||
onJoinClick: View.OnClickListener): VectorEpoxyModel<*> {
|
onJoinClick: View.OnClickListener): VectorEpoxyModel<*> {
|
||||||
return SpaceChildInfoItem_()
|
return SpaceChildInfoItem_()
|
||||||
.id("sug_${spaceChildInfo.childRoomId}")
|
.id("sug_${spaceChildInfo.childRoomId}")
|
||||||
.matrixItem(MatrixItem.RoomItem(spaceChildInfo.childRoomId, spaceChildInfo.name, spaceChildInfo.avatarUrl))
|
.matrixItem(spaceChildInfo.toMatrixItem())
|
||||||
.avatarRenderer(avatarRenderer)
|
.avatarRenderer(avatarRenderer)
|
||||||
.topic(spaceChildInfo.topic)
|
.topic(spaceChildInfo.topic)
|
||||||
.buttonLabel(stringProvider.getString(R.string.join))
|
.buttonLabel(stringProvider.getString(R.string.join))
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkData
|
import org.matrix.android.sdk.api.session.permalinks.PermalinkData
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.peeking.PeekResult
|
import org.matrix.android.sdk.api.session.room.peeking.PeekResult
|
||||||
import org.matrix.android.sdk.api.session.space.SpaceService
|
import org.matrix.android.sdk.api.session.space.JoinSpaceResult
|
||||||
import org.matrix.android.sdk.api.session.user.model.User
|
import org.matrix.android.sdk.api.session.user.model.User
|
||||||
import org.matrix.android.sdk.api.util.MatrixItem
|
import org.matrix.android.sdk.api.util.MatrixItem
|
||||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||||
|
@ -281,7 +281,7 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
|
||||||
if (joinResult.isSuccess()) {
|
if (joinResult.isSuccess()) {
|
||||||
_viewEvents.post(MatrixToViewEvents.NavigateToSpace(joinSpace.spaceID))
|
_viewEvents.post(MatrixToViewEvents.NavigateToSpace(joinSpace.spaceID))
|
||||||
} else {
|
} else {
|
||||||
val errMsg = errorFormatter.toHumanReadable((joinResult as? SpaceService.JoinSpaceResult.Fail)?.error)
|
val errMsg = errorFormatter.toHumanReadable((joinResult as? JoinSpaceResult.Fail)?.error)
|
||||||
_viewEvents.post(MatrixToViewEvents.ShowModalError(errMsg))
|
_viewEvents.post(MatrixToViewEvents.ShowModalError(errMsg))
|
||||||
}
|
}
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ sealed class RoomSettingsAction : VectorViewModelAction {
|
||||||
data class SetRoomName(val newName: String) : RoomSettingsAction()
|
data class SetRoomName(val newName: String) : RoomSettingsAction()
|
||||||
data class SetRoomTopic(val newTopic: String) : RoomSettingsAction()
|
data class SetRoomTopic(val newTopic: String) : RoomSettingsAction()
|
||||||
data class SetRoomHistoryVisibility(val visibility: RoomHistoryVisibility) : RoomSettingsAction()
|
data class SetRoomHistoryVisibility(val visibility: RoomHistoryVisibility) : RoomSettingsAction()
|
||||||
data class SetRoomJoinRule(val roomJoinRule: RoomJoinRules?) : RoomSettingsAction()
|
data class SetRoomJoinRule(val roomJoinRule: RoomJoinRules) : RoomSettingsAction()
|
||||||
data class SetRoomGuestAccess(val guestAccess: GuestAccess) : RoomSettingsAction()
|
data class SetRoomGuestAccess(val guestAccess: GuestAccess) : RoomSettingsAction()
|
||||||
|
|
||||||
object Save : RoomSettingsAction()
|
object Save : RoomSettingsAction()
|
||||||
|
|
|
@ -148,7 +148,7 @@ class SpaceSummaryController @Inject constructor(
|
||||||
?.forEach { groupSummary ->
|
?.forEach { groupSummary ->
|
||||||
val isSelected = selected is RoomGroupingMethod.BySpace && groupSummary.roomId == selected.space()?.roomId
|
val isSelected = selected is RoomGroupingMethod.BySpace && groupSummary.roomId == selected.space()?.roomId
|
||||||
// does it have children?
|
// does it have children?
|
||||||
val subSpaces = groupSummary.children?.filter { childInfo ->
|
val subSpaces = groupSummary.spaceChildren?.filter { childInfo ->
|
||||||
summaries.indexOfFirst { it.roomId == childInfo.childRoomId } != -1
|
summaries.indexOfFirst { it.roomId == childInfo.childRoomId } != -1
|
||||||
}
|
}
|
||||||
val hasChildren = (subSpaces?.size ?: 0) > 0
|
val hasChildren = (subSpaces?.size ?: 0) > 0
|
||||||
|
|
|
@ -29,7 +29,7 @@ data class CreateSpaceState(
|
||||||
val spaceType: SpaceType? = null,
|
val spaceType: SpaceType? = null,
|
||||||
val spaceTopology: SpaceTopology? = null,
|
val spaceTopology: SpaceTopology? = null,
|
||||||
val nameInlineError: String? = null,
|
val nameInlineError: String? = null,
|
||||||
val defaultRooms: Map<Int, String?>? = null,
|
val defaultRooms: Map<Int /** position in form */, String?>? = null,
|
||||||
val creationResult: Async<String> = Uninitialized
|
val creationResult: Async<String> = Uninitialized
|
||||||
) : MvRxState {
|
) : MvRxState {
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class SpaceDetailEpoxyController @Inject constructor(
|
||||||
enabled(true)
|
enabled(true)
|
||||||
imageUri(data?.avatarUri)
|
imageUri(data?.avatarUri)
|
||||||
avatarRenderer(avatarRenderer)
|
avatarRenderer(avatarRenderer)
|
||||||
matrixItem(data?.name?.let { MatrixItem.RoomItem("", it, null).takeIf { !it.displayName.isNullOrBlank() } })
|
matrixItem(data?.name?.let { MatrixItem.RoomItem("!", it, null).takeIf { !it.displayName.isNullOrBlank() } })
|
||||||
clickListener { listener?.onAvatarChange() }
|
clickListener { listener?.onAvatarChange() }
|
||||||
deleteListener { listener?.onAvatarDelete() }
|
deleteListener { listener?.onAvatarDelete() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ class SpaceDirectoryViewModel @AssistedInject constructor(
|
||||||
val spaceSum = session.getRoomSummary(initialState.spaceId)
|
val spaceSum = session.getRoomSummary(initialState.spaceId)
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
childList = spaceSum?.children ?: emptyList(),
|
childList = spaceSum?.spaceChildren ?: emptyList(),
|
||||||
spaceSummaryApiResult = Loading()
|
spaceSummaryApiResult = Loading()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -95,17 +95,12 @@ class SpaceDirectoryViewModel @AssistedInject constructor(
|
||||||
session
|
session
|
||||||
.rx()
|
.rx()
|
||||||
.liveRoomSummaries(queryParams)
|
.liveRoomSummaries(queryParams)
|
||||||
.subscribe { list ->
|
.map {
|
||||||
val joinedRoomIds = list
|
it.map { it.roomId }.toSet()
|
||||||
?.map { it.roomId }
|
}
|
||||||
?.toSet()
|
.execute {
|
||||||
?: emptySet()
|
copy(joinedRoomsIds = it.invoke() ?: emptySet())
|
||||||
|
|
||||||
setState {
|
|
||||||
copy(joinedRoomsIds = joinedRoomIds)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.disposeOnClear()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeMembershipChanges() {
|
private fun observeMembershipChanges() {
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||||
|
|
||||||
class AddRoomError(val errorList: Map<String, Throwable>) : Throwable() {
|
class AddRoomError(val errorList: Map<String, Throwable>) : Throwable() {
|
||||||
override fun getLocalizedMessage(): String? {
|
override fun getLocalizedMessage(): String? {
|
||||||
return errorList.map { it.value.localizedMessage }.joinToString(",")
|
return errorList.map { it.value.localizedMessage }.joinToString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,6 @@ import im.vector.app.core.platform.VectorViewModelAction
|
||||||
|
|
||||||
sealed class SpaceManagedSharedAction : VectorViewModelAction {
|
sealed class SpaceManagedSharedAction : VectorViewModelAction {
|
||||||
object HandleBack : SpaceManagedSharedAction()
|
object HandleBack : SpaceManagedSharedAction()
|
||||||
object ShowLoading: SpaceManagedSharedAction()
|
object ShowLoading : SpaceManagedSharedAction()
|
||||||
object HideLoading: SpaceManagedSharedAction()
|
object HideLoading : SpaceManagedSharedAction()
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,6 @@ import im.vector.app.core.platform.VectorViewEvents
|
||||||
|
|
||||||
sealed class SpaceManagedSharedViewEvents : VectorViewEvents {
|
sealed class SpaceManagedSharedViewEvents : VectorViewEvents {
|
||||||
object Finish : SpaceManagedSharedViewEvents()
|
object Finish : SpaceManagedSharedViewEvents()
|
||||||
object ShowLoading: SpaceManagedSharedViewEvents()
|
object ShowLoading : SpaceManagedSharedViewEvents()
|
||||||
object HideLoading: SpaceManagedSharedViewEvents()
|
object HideLoading : SpaceManagedSharedViewEvents()
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomType
|
import org.matrix.android.sdk.api.session.room.model.RoomType
|
||||||
import org.matrix.android.sdk.api.session.room.peeking.PeekResult
|
import org.matrix.android.sdk.api.session.room.peeking.PeekResult
|
||||||
import org.matrix.android.sdk.api.session.space.SpaceService
|
import org.matrix.android.sdk.api.session.space.JoinSpaceResult
|
||||||
import org.matrix.android.sdk.internal.session.space.peeking.SpacePeekResult
|
import org.matrix.android.sdk.internal.session.space.peeking.SpacePeekResult
|
||||||
import org.matrix.android.sdk.internal.session.space.peeking.SpaceSubChildPeekResult
|
import org.matrix.android.sdk.internal.session.space.peeking.SpaceSubChildPeekResult
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
@ -102,12 +102,12 @@ class SpacePreviewViewModel @AssistedInject constructor(
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
val joinResult = session.spaceService().joinSpace(initialState.idOrAlias, null, spaceVia)
|
val joinResult = session.spaceService().joinSpace(initialState.idOrAlias, null, spaceVia)
|
||||||
when (joinResult) {
|
when (joinResult) {
|
||||||
SpaceService.JoinSpaceResult.Success,
|
JoinSpaceResult.Success,
|
||||||
is SpaceService.JoinSpaceResult.PartialSuccess -> {
|
is JoinSpaceResult.PartialSuccess -> {
|
||||||
// For now we don't handle partial success, it's just success
|
// For now we don't handle partial success, it's just success
|
||||||
_viewEvents.post(SpacePreviewViewEvents.JoinSuccess)
|
_viewEvents.post(SpacePreviewViewEvents.JoinSuccess)
|
||||||
}
|
}
|
||||||
is SpaceService.JoinSpaceResult.Fail -> {
|
is JoinSpaceResult.Fail -> {
|
||||||
_viewEvents.post(SpacePreviewViewEvents.JoinFailure(joinResult.error.toString()))
|
_viewEvents.post(SpacePreviewViewEvents.JoinFailure(joinResult.error.toString()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,13 +60,13 @@ class SharedPreferencesUiStateRepository @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun storeSelectedSpace(spaceId: String?, sessionId: String) {
|
override fun storeSelectedSpace(spaceId: String?, sessionId: String) {
|
||||||
sharedPreferences.edit(true) {
|
sharedPreferences.edit {
|
||||||
putString("$KEY_SELECTED_SPACE@$sessionId", spaceId)
|
putString("$KEY_SELECTED_SPACE@$sessionId", spaceId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun storeSelectedGroup(groupId: String?, sessionId: String) {
|
override fun storeSelectedGroup(groupId: String?, sessionId: String) {
|
||||||
sharedPreferences.edit(true) {
|
sharedPreferences.edit {
|
||||||
putString("$KEY_SELECTED_GROUP@$sessionId", groupId)
|
putString("$KEY_SELECTED_GROUP@$sessionId", groupId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,36 +18,36 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:baselineAligned="false"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal">
|
||||||
android:baselineAligned="false">
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/groupToolbarAvatarImageView"
|
android:id="@+id/groupToolbarAvatarImageView"
|
||||||
android:contentDescription="@string/a11y_open_drawer"
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
|
android:contentDescription="@string/a11y_open_drawer"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
android:layout_width="40dp"
|
|
||||||
android:layout_height="40dp">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:importantForAccessibility="no"
|
|
||||||
android:layout_width="28dp"
|
android:layout_width="28dp"
|
||||||
android:layout_height="28dp"
|
android:layout_height="28dp"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:src="@drawable/ic_space_icons"
|
|
||||||
app:tint="?riotx_text_secondary"
|
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginStart="4dp"
|
||||||
/>
|
android:importantForAccessibility="no"
|
||||||
|
android:src="@drawable/ic_space_icons"
|
||||||
|
app:tint="?riotx_text_secondary" />
|
||||||
|
|
||||||
<!-- Not yet done -->
|
|
||||||
<im.vector.app.features.home.room.list.UnreadCounterBadgeView
|
<im.vector.app.features.home.room.list.UnreadCounterBadgeView
|
||||||
android:id="@+id/drawerUnreadCounterBadgeView"
|
android:id="@+id/drawerUnreadCounterBadgeView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_marginEnd="0dp"
|
android:layout_marginEnd="0dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:minWidth="16dp"
|
android:minWidth="16dp"
|
||||||
|
@ -57,20 +57,18 @@
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="10sp"
|
android:textSize="10sp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
tools:background="@drawable/bg_unread_highlight"
|
tools:background="@drawable/bg_unread_highlight"
|
||||||
tools:text="4"
|
tools:text="4"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/homeToolbarContent"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:id="@+id/homeToolbarContent"
|
|
||||||
android:paddingStart="8dp"
|
android:paddingStart="8dp"
|
||||||
android:paddingEnd="8dp">
|
android:paddingEnd="8dp">
|
||||||
|
|
||||||
|
@ -90,14 +88,14 @@
|
||||||
android:id="@+id/groupToolbarSpaceTitleView"
|
android:id="@+id/groupToolbarSpaceTitleView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:visibility="visible"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?riotx_text_primary"
|
android:textColor="?riotx_text_primary"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
tools:text="@tools:sample/lorem/random" />
|
android:visibility="gone"
|
||||||
|
tools:text="@tools:sample/lorem/random"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,9 @@
|
||||||
android:id="@+id/publicRoomsFilter"
|
android:id="@+id/publicRoomsFilter"
|
||||||
style="@style/VectorSearchView"
|
style="@style/VectorSearchView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/addRoomToSpaceToolbar"
|
app:layout_constraintTop_toBottomOf="@+id/addRoomToSpaceToolbar"
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
style="?progressBarStyle"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center" />
|
android:layout_gravity="center" />
|
||||||
|
|
Loading…
Reference in a new issue