mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 11:26:01 +03:00
Code review
This commit is contained in:
parent
97114b4f48
commit
9687a59371
10 changed files with 17 additions and 18 deletions
|
@ -20,7 +20,7 @@ import org.matrix.android.sdk.api.session.events.model.Event
|
|||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo
|
||||
|
||||
data class SpaceHierarchySummary(
|
||||
data class SpaceHierarchyData(
|
||||
val rootSummary: RoomSummary,
|
||||
val children: List<SpaceChildInfo>,
|
||||
val childrenState: List<Event>,
|
|
@ -21,7 +21,6 @@ import androidx.lifecycle.LiveData
|
|||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
import org.matrix.android.sdk.internal.session.space.SpaceHierarchySummary
|
||||
import org.matrix.android.sdk.internal.session.space.peeking.SpacePeekResult
|
||||
|
||||
typealias SpaceSummaryQueryParams = RoomSummaryQueryParams
|
||||
|
@ -61,7 +60,6 @@ interface SpaceService {
|
|||
* Get's information of a space by querying the server
|
||||
* @param suggestedOnly If true, return only child events and rooms where the m.space.child event has suggested: true.
|
||||
* @param limit a client-defined limit to the maximum number of rooms to return per page. Must be a non-negative integer.
|
||||
* @param maxDepth: Optional: The maximum depth in the tree (from the root room) to return.
|
||||
* @param from: Optional. Pagination token given to retrieve the next set of rooms. Note that if a pagination token is provided,
|
||||
* then the parameters given for suggested_only and max_depth must be the same.
|
||||
*/
|
||||
|
@ -70,7 +68,7 @@ interface SpaceService {
|
|||
limit: Int? = null,
|
||||
from: String? = null,
|
||||
// when paginating, pass back the m.space.child state events
|
||||
knownStateList: List<Event>? = null): SpaceHierarchySummary
|
||||
knownStateList: List<Event>? = null): SpaceHierarchyData
|
||||
|
||||
/**
|
||||
* Get a live list of space summaries. This list is refreshed as soon as the data changes.
|
||||
|
|
|
@ -36,6 +36,7 @@ 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.JoinSpaceResult
|
||||
import org.matrix.android.sdk.api.session.space.Space
|
||||
import org.matrix.android.sdk.api.session.space.SpaceHierarchyData
|
||||
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.model.SpaceChildContent
|
||||
|
@ -112,7 +113,7 @@ internal class DefaultSpaceService @Inject constructor(
|
|||
suggestedOnly: Boolean?,
|
||||
limit: Int?,
|
||||
from: String?,
|
||||
knownStateList: List<Event>?): SpaceHierarchySummary {
|
||||
knownStateList: List<Event>?): SpaceHierarchyData {
|
||||
return resolveSpaceInfoTask.execute(
|
||||
ResolveSpaceInfoTask.Params(
|
||||
spaceId = spaceId, limit = limit, maxDepth = 1, from = from, suggestedOnly = suggestedOnly
|
||||
|
@ -164,7 +165,7 @@ internal class DefaultSpaceService @Inject constructor(
|
|||
}.orEmpty()
|
||||
}
|
||||
.orEmpty()
|
||||
SpaceHierarchySummary(
|
||||
SpaceHierarchyData(
|
||||
rootSummary = root,
|
||||
children = children,
|
||||
childrenState = spaceDesc?.childrenState.orEmpty(),
|
||||
|
|
|
@ -24,10 +24,10 @@ import retrofit2.http.Query
|
|||
internal interface SpaceApi {
|
||||
|
||||
/**
|
||||
* @param suggestedOnly Optional. If true, return only child events and rooms where the m.space.child event has suggested: true.
|
||||
* @param limit: Optional: a client-defined limit to the maximum number of rooms to return per page. Must be a non-negative integer.
|
||||
* @param max_depth: Optional: The maximum depth in the tree (from the root room) to return.
|
||||
* @param maxDepth: Optional: The maximum depth in the tree (from the root room) to return.
|
||||
* The deepest depth returned will not include children events. Defaults to no-limit. Must be a non-negative integer.
|
||||
*
|
||||
* @param from: Optional. Pagination token given to retrieve the next set of rooms.
|
||||
* Note that if a pagination token is provided, then the parameters given for suggested_only and max_depth must be the same.
|
||||
*/
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.matrix.android.sdk.api.session.events.model.Event
|
|||
* The fields are the same as those returned by /publicRooms (see spec), with the addition of:
|
||||
* room_type: the value of the m.type field from the room's m.room.create event, if any.
|
||||
* children_state: The m.space.child events of the room.
|
||||
* For each event, only the following fields are included1: type, state_key, content, room_id, sender,
|
||||
* For each event, only the following fields are included: type, state_key, content, room_id, sender,
|
||||
* with the addition of: origin_server_ts: This is required for sorting of rooms as specified below.
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
|
|
|
@ -62,7 +62,7 @@ class SpaceCardRenderer @Inject constructor(
|
|||
inCard.matrixToAccessImage.isVisible = true
|
||||
inCard.matrixToAccessImage.setImageResource(R.drawable.ic_room_private)
|
||||
}
|
||||
val memberCount = spaceSummary.joinedMembersCount?.let { it - 1 } ?: 0
|
||||
val memberCount = spaceSummary.joinedMembersCount ?: 0
|
||||
if (memberCount != 0) {
|
||||
inCard.matrixToMemberPills.isVisible = true
|
||||
inCard.spaceChildMemberCountText.text = stringProvider.getQuantityString(R.plurals.room_title_members, memberCount, memberCount)
|
||||
|
|
|
@ -175,7 +175,7 @@ class SpaceDirectoryController @Inject constructor(
|
|||
errorWithRetryItem {
|
||||
id("error_${currentRootId}_${hierarchySummary.nextToken}")
|
||||
text(host.errorFormatter.toHumanReadable(paginationStatus.error))
|
||||
listener { host.listener?.retry() }
|
||||
listener { host.listener?.loadAdditionalItemsIfNeeded() }
|
||||
}
|
||||
} else {
|
||||
loadingItem {
|
||||
|
|
|
@ -21,13 +21,13 @@ import com.airbnb.mvrx.MvRxState
|
|||
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
|
||||
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.internal.session.space.SpaceHierarchySummary
|
||||
import org.matrix.android.sdk.api.session.space.SpaceHierarchyData
|
||||
|
||||
data class SpaceDirectoryState(
|
||||
// The current filter
|
||||
val spaceId: String,
|
||||
val currentFilter: String = "",
|
||||
val apiResults: Map<String, Async<SpaceHierarchySummary>> = emptyMap(),
|
||||
val apiResults: Map<String, Async<SpaceHierarchyData>> = emptyMap(),
|
||||
val currentRootSummary: RoomSummary? = null,
|
||||
val childList: List<SpaceChildInfo> = emptyList(),
|
||||
val hierarchyStack: List<String> = emptyList(),
|
||||
|
@ -37,7 +37,7 @@ data class SpaceDirectoryState(
|
|||
val changeMembershipStates: Map<String, ChangeMembershipState> = emptyMap(),
|
||||
val canAddRooms: Boolean = false,
|
||||
// cached room summaries of known rooms, we use it because computed room name would be better using it
|
||||
val knownRoomSummaries : List<RoomSummary> = emptyList(),
|
||||
val knownRoomSummaries: List<RoomSummary> = emptyList(),
|
||||
val paginationStatus: Map<String, Async<Unit>> = emptyMap()
|
||||
) : MvRxState {
|
||||
constructor(args: SpaceDirectoryArgs) : this(
|
||||
|
|
|
@ -20,18 +20,18 @@ import com.airbnb.mvrx.Async
|
|||
import com.airbnb.mvrx.MvRxState
|
||||
import com.airbnb.mvrx.Uninitialized
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
import org.matrix.android.sdk.internal.session.space.SpaceHierarchySummary
|
||||
import org.matrix.android.sdk.api.session.space.SpaceHierarchyData
|
||||
|
||||
data class SpaceManageRoomViewState(
|
||||
val spaceId: String,
|
||||
val spaceSummary: Async<RoomSummary> = Uninitialized,
|
||||
val childrenInfo: Async<SpaceHierarchySummary> = Uninitialized,
|
||||
val childrenInfo: Async<SpaceHierarchyData> = Uninitialized,
|
||||
val selectedRooms: List<String> = emptyList(),
|
||||
val currentFilter: String = "",
|
||||
val actionState: Async<Unit> = Uninitialized,
|
||||
val paginationStatus: Async<Unit> = Uninitialized,
|
||||
// cached room summaries of known rooms, we use it because computed room name would be better using it
|
||||
val knownRoomSummaries : List<RoomSummary> = emptyList()
|
||||
val knownRoomSummaries: List<RoomSummary> = emptyList()
|
||||
) : MvRxState {
|
||||
constructor(args: SpaceManageArgs) : this(
|
||||
spaceId = args.spaceId
|
||||
|
|
|
@ -101,7 +101,7 @@ class SpaceManageRoomsController @Inject constructor(
|
|||
errorWithRetryItem {
|
||||
id("error_$nextToken")
|
||||
text(host.errorFormatter.toHumanReadable(paginationStatus.error))
|
||||
listener { host.listener?.retry() }
|
||||
listener { host.listener?.loadAdditionalItemsIfNeeded() }
|
||||
}
|
||||
} else {
|
||||
loadingItem {
|
||||
|
|
Loading…
Reference in a new issue