diff --git a/MatrixSDK/Contrib/Swift/MXRestClient.swift b/MatrixSDK/Contrib/Swift/MXRestClient.swift index 964aad134b..7eb03ebb67 100644 --- a/MatrixSDK/Contrib/Swift/MXRestClient.swift +++ b/MatrixSDK/Contrib/Swift/MXRestClient.swift @@ -1883,10 +1883,12 @@ public extension MXRestClient { /// - spaceId: The room id of the queried space. /// - suggestedOnly: If `true`, return only child events and rooms where the `m.space.child` event has `suggested: true`. /// - limit: Optional. A limit to the maximum number of children to return per space. `-1` for no limit + /// - maxDepth: Optional. The maximum depth in the tree (from the root room) to return. `-1` for no limit + /// - paginationToken: Optional. Pagination token given to retrieve the next set of rooms. /// - parameters: Space children request parameters. /// - completion: A closure called when the operation completes. /// - Returns: a `MXHTTPOperation` instance. - @nonobjc @discardableResult func getSpaceChildrenForSpace(withId spaceId: String, suggestedOnly: Bool, limit: Int?, completion: @escaping (_ response: MXResponse) -> Void) -> MXHTTPOperation { - return __getSpaceChildrenForSpace(withId: spaceId, suggestedOnly: suggestedOnly, limit: limit ?? -1, success: currySuccess(completion), failure: curryFailure(completion)) + @nonobjc @discardableResult func getSpaceChildrenForSpace(withId spaceId: String, suggestedOnly: Bool, limit: Int?, maxDepth: Int?, paginationToken: String?, completion: @escaping (_ response: MXResponse) -> Void) -> MXHTTPOperation { + return __getSpaceChildrenForSpace(withId: spaceId, suggestedOnly: suggestedOnly, limit: limit ?? -1, maxDepth: maxDepth ?? -1, paginationToken: paginationToken, success: currySuccess(completion), failure: curryFailure(completion)) } } diff --git a/MatrixSDK/Data/RoomList/Common/MXSuggestedRoomListDataFetcher.swift b/MatrixSDK/Data/RoomList/Common/MXSuggestedRoomListDataFetcher.swift index 98d6580358..0a54251098 100644 --- a/MatrixSDK/Data/RoomList/Common/MXSuggestedRoomListDataFetcher.swift +++ b/MatrixSDK/Data/RoomList/Common/MXSuggestedRoomListDataFetcher.swift @@ -183,9 +183,7 @@ internal class MXSuggestedRoomListDataFetcher: NSObject, MXRoomListDataFetcher { // do the request // limit should be -1 for no limit let limit: Int = numberOfItems < 0 ? -1 : numberOfItems - currentHttpOperation = spaceService.getSpaceChildrenForSpace(withId: space.spaceId, - suggestedOnly: true, - limit: limit) { [weak self] response in + currentHttpOperation = spaceService.getSpaceChildrenForSpace(withId: space.spaceId, suggestedOnly: true, limit: limit, maxDepth: 1, paginationToken: nil) { [weak self] response in guard let self = self else { return } switch response { case .success(let summary): diff --git a/MatrixSDK/Data/RoomList/MXRoomListDataSortOptions.swift b/MatrixSDK/Data/RoomList/MXRoomListDataSortOptions.swift index 29a1ce12f2..d14df21e27 100644 --- a/MatrixSDK/Data/RoomList/MXRoomListDataSortOptions.swift +++ b/MatrixSDK/Data/RoomList/MXRoomListDataSortOptions.swift @@ -78,9 +78,10 @@ public struct MXRoomListDataSortOptions: Equatable { internal var sortDescriptors: [NSSortDescriptor] { var result: [NSSortDescriptor] = [] - if suggested { - result.append(NSSortDescriptor(keyPath: \MXRoomSummaryProtocol.spaceChildInfo?.order, ascending: false)) - } + // TODO: reintroduce order once it will be supported +// if suggested { +// result.append(NSSortDescriptor(keyPath: \MXRoomSummaryProtocol.spaceChildInfo?.order, ascending: false)) +// } if invitesFirst { result.append(NSSortDescriptor(keyPath: \MXRoomSummaryProtocol.membership, ascending: true)) diff --git a/MatrixSDK/MXRestClient.h b/MatrixSDK/MXRestClient.h index daa72402c3..df98546bb8 100644 --- a/MatrixSDK/MXRestClient.h +++ b/MatrixSDK/MXRestClient.h @@ -2786,12 +2786,16 @@ Note: Clients should consider avoiding this endpoint for URLs posted in encrypte /// @param spaceId The room id of the queried space. /// @param suggestedOnly If `true`, return only child events and rooms where the `m.space.child` event has `suggested: true`. /// @param limit A limit to the maximum number of children to return per space. `-1` for no limit +/// @param maxDepth The maximum depth in the tree (from the root room) to return. The deepest depth returned will not include children events. `-1` for no limit +/// @param paginationToken Pagination token given to retrieve the next set of rooms. /// @param success A block object called when the operation succeeds. It provides a `MXSpaceChildrenResponse` object. /// @param failure A block object called when the operation fails. /// @return a MXHTTPOperation instance. - (MXHTTPOperation*)getSpaceChildrenForSpaceWithId:(NSString*)spaceId suggestedOnly:(BOOL)suggestedOnly limit:(NSInteger)limit + maxDepth:(NSInteger)maxDepth + paginationToken:(NSString*)paginationToken success:(void (^)(MXSpaceChildrenResponse *spaceChildrenResponse))success failure:(void (^)(NSError *error))failure NS_REFINED_FOR_SWIFT; @end diff --git a/MatrixSDK/MXRestClient.m b/MatrixSDK/MXRestClient.m index a1e1c89d46..18923406fc 100644 --- a/MatrixSDK/MXRestClient.m +++ b/MatrixSDK/MXRestClient.m @@ -5496,12 +5496,16 @@ - (MXHTTPOperation*)relationsForEvent:(NSString*)eventId - (MXHTTPOperation*)getSpaceChildrenForSpaceWithId:(NSString*)spaceId suggestedOnly:(BOOL)suggestedOnly limit:(NSInteger)limit + maxDepth:(NSInteger)maxDepth + paginationToken:(NSString*)paginationToken success:(void (^)(MXSpaceChildrenResponse *spaceChildrenResponse))success failure:(void (^)(NSError *error))failure { - NSString *maxRoomParameter = limit >= 0 ? [NSString stringWithFormat:@"&max_rooms_per_space=%ld", (long)limit] : @""; - NSString *path = [NSString stringWithFormat:@"%@/org.matrix.msc2946/rooms/%@/spaces?suggested_only=%@%@", - kMXAPIPrefixPathUnstable, spaceId, suggestedOnly ? @"true": @"false", maxRoomParameter]; + NSString *limitParam = limit >= 0 ? [NSString stringWithFormat:@"&limit=%ld", (long)limit] : @""; + NSString *maxDepthParam = maxDepth >= 0 ? [NSString stringWithFormat:@"&max_depth=%ld", (long)maxDepth] : @""; + NSString *fromParam = paginationToken != nil ? [NSString stringWithFormat:@"&from=%@", paginationToken] : @""; + NSString *path = [NSString stringWithFormat:@"%@/org.matrix.msc2946/rooms/%@/hierarchy?suggested_only=%@%@%@%@", + kMXAPIPrefixPathUnstable, spaceId, suggestedOnly ? @"true": @"false", limitParam, maxDepthParam, fromParam]; MXWeakify(self); return [httpClient requestWithMethod:@"GET" diff --git a/MatrixSDK/Space/MXSpaceChildInfo.swift b/MatrixSDK/Space/MXSpaceChildInfo.swift index f4dc0f387d..3cd392eed4 100644 --- a/MatrixSDK/Space/MXSpaceChildInfo.swift +++ b/MatrixSDK/Space/MXSpaceChildInfo.swift @@ -47,10 +47,6 @@ public class MXSpaceChildInfo: NSObject { /// The Matrix content URI of the space avatar. public let avatarUrl: String? - /// The order key is a string which is used to provide a default ordering of siblings in the room list. - /// Orders should be a string of ascii characters in the range \x20 (space) to \x7F (~), and should be less or equal 50 characters. - public let order: String? - /// The number of members joined to the room. public let activeMemberCount: Int @@ -60,18 +56,9 @@ public class MXSpaceChildInfo: NSObject { /// `true` if the room is suggested. `false` otherwise. public let suggested: Bool - /// List of space parent IDs - public let parentIds: Set - /// List of children IDs public let childrenIds: [String] - /// Gives a list of candidate servers that can be used to join the space. - public let viaServers: [String] - - /// The parent space room id. - public let parentRoomId: String? - /// Display name of the space child public var displayName: String? { return self.name != nil ? self.name : self.canonicalAlias @@ -87,14 +74,10 @@ public class MXSpaceChildInfo: NSObject { topic: String?, canonicalAlias: String?, avatarUrl: String?, - order: String?, activeMemberCount: Int, autoJoin: Bool, suggested: Bool, - parentIds: Set, - childrenIds: [String], - viaServers: [String], - parentRoomId: String?) { + childrenIds: [String]) { self.childRoomId = childRoomId self.isKnown = isKnown self.roomTypeString = roomTypeString @@ -103,13 +86,9 @@ public class MXSpaceChildInfo: NSObject { self.topic = topic self.canonicalAlias = canonicalAlias self.avatarUrl = avatarUrl - self.order = order self.activeMemberCount = activeMemberCount self.autoJoin = autoJoin self.suggested = suggested - self.parentIds = parentIds self.childrenIds = childrenIds - self.viaServers = viaServers - self.parentRoomId = parentRoomId } } diff --git a/MatrixSDK/Space/MXSpaceChildSummaryResponse.h b/MatrixSDK/Space/MXSpaceChildSummaryResponse.h index 8aea1f78f7..5de3046c89 100644 --- a/MatrixSDK/Space/MXSpaceChildSummaryResponse.h +++ b/MatrixSDK/Space/MXSpaceChildSummaryResponse.h @@ -16,6 +16,7 @@ #import #import "MXJSONModel.h" +#import "MXEvent.h" NS_ASSUME_NONNULL_BEGIN @@ -23,30 +24,31 @@ NS_ASSUME_NONNULL_BEGIN @interface MXSpaceChildSummaryResponse : MXJSONModel /// The ID of the room. -@property (nonatomic) NSString* roomId; +@property (nonatomic) NSString *roomId; /// The room type, which is m.space for subspaces. /// It can be omitted if there is no room type in which case it should be interpreted as a normal room. -@property (nonatomic, nullable) NSString* roomType; +@property (nonatomic, nullable) NSString *roomType; /// The name of the room, if any. -@property (nonatomic, nullable) NSString* name; +@property (nonatomic, nullable) NSString *name; /// The topic of the room, if any. -@property (nonatomic, nullable) NSString* topic; +@property (nonatomic, nullable) NSString *topic; /// The URL for the room's avatar, if one is set. -@property (nonatomic, nullable) NSString* avatarUrl; +@property (nonatomic, nullable) NSString *avatarUrl; -/// Aliases of the room. May be empty. -@property (nonatomic, nullable) NSArray* aliases; +@property (nonatomic, nullable) NSString *joinRules; + +@property (nonatomic) NSTimeInterval creationTime; /// The canonical alias of the room, if any. -@property (nonatomic, nullable) NSString* canonicalAlias; +@property (nonatomic, nullable) NSString *canonicalAlias; /// Whether guest users may join the room and participate in it. If they can, /// they will be subject to ordinary power level rules like any other user. -@property (nonatomic, getter = areGuestCanJoin) BOOL guestCanJoin; +@property (nonatomic) BOOL guestCanJoin; /// Whether the room may be viewed by guest users without joining. @property (nonatomic, getter = isWorldReadable) BOOL worldReadable; @@ -54,6 +56,9 @@ NS_ASSUME_NONNULL_BEGIN /// The number of members joined to the room. @property (nonatomic) NSInteger numJoinedMembers; +/// These are the edges of the graph. The objects in the array are complete (or stripped?) m.room.parent or m.space.child events. +@property (nonatomic, nullable) NSArray *childrenState; + @end NS_ASSUME_NONNULL_END diff --git a/MatrixSDK/Space/MXSpaceChildSummaryResponse.m b/MatrixSDK/Space/MXSpaceChildSummaryResponse.m index 6b2551fbb6..957f102125 100644 --- a/MatrixSDK/Space/MXSpaceChildSummaryResponse.m +++ b/MatrixSDK/Space/MXSpaceChildSummaryResponse.m @@ -40,11 +40,13 @@ + (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary MXJSONModelSetString(spaceChildSummaryResponse.name, JSONDictionary[@"name"]); MXJSONModelSetString(spaceChildSummaryResponse.topic, JSONDictionary[@"topic"]); MXJSONModelSetString(spaceChildSummaryResponse.avatarUrl, JSONDictionary[@"avatar_url"]); - MXJSONModelSetArray(spaceChildSummaryResponse.aliases, JSONDictionary[@"aliases"]); MXJSONModelSetString(spaceChildSummaryResponse.canonicalAlias, JSONDictionary[@"canonical_alias"]); MXJSONModelSetBoolean(spaceChildSummaryResponse.guestCanJoin, JSONDictionary[@"guest_can_join"]); MXJSONModelSetBoolean(spaceChildSummaryResponse.worldReadable, JSONDictionary[@"world_readable"]); MXJSONModelSetInteger(spaceChildSummaryResponse.numJoinedMembers, JSONDictionary[@"num_joined_members"]); + MXJSONModelSetUInteger(spaceChildSummaryResponse.creationTime, JSONDictionary[@"creation_ts"]); + MXJSONModelSetString(spaceChildSummaryResponse.joinRules, JSONDictionary[@"join_rules"]); + MXJSONModelSetMXJSONModelArray(spaceChildSummaryResponse.childrenState, MXEvent, JSONDictionary[@"children_state"]); } return spaceChildSummaryResponse; diff --git a/MatrixSDK/Space/MXSpaceChildrenResponse.h b/MatrixSDK/Space/MXSpaceChildrenResponse.h index a381bffd20..993998f93a 100644 --- a/MatrixSDK/Space/MXSpaceChildrenResponse.h +++ b/MatrixSDK/Space/MXSpaceChildrenResponse.h @@ -17,7 +17,6 @@ #import #import "MXJSONModel.h" #import "MXSpaceChildSummaryResponse.h" -#import "MXEvent.h" NS_ASSUME_NONNULL_BEGIN @@ -30,9 +29,6 @@ NS_ASSUME_NONNULL_BEGIN /// Rooms information like name/avatar/type ... @property (nonatomic, nullable) NSArray* rooms; -/// These are the edges of the graph. The objects in the array are complete (or stripped?) m.room.parent or m.space.child events. -@property (nonatomic, nullable) NSArray* events; - @end NS_ASSUME_NONNULL_END diff --git a/MatrixSDK/Space/MXSpaceChildrenResponse.m b/MatrixSDK/Space/MXSpaceChildrenResponse.m index 763e7b7e88..3e9837e445 100644 --- a/MatrixSDK/Space/MXSpaceChildrenResponse.m +++ b/MatrixSDK/Space/MXSpaceChildrenResponse.m @@ -26,7 +26,6 @@ + (id)modelFromJSON:(NSDictionary *)JSONDictionary { MXJSONModelSetString(spaceChildrenResponse.nextBatch, JSONDictionary[@"next_batch"]); MXJSONModelSetMXJSONModelArray(spaceChildrenResponse.rooms, MXSpaceChildSummaryResponse, JSONDictionary[@"rooms"]); - MXJSONModelSetMXJSONModelArray(spaceChildrenResponse.events, MXEvent, JSONDictionary[@"events"]); } return spaceChildrenResponse; diff --git a/MatrixSDK/Space/MXSpaceChildrenSummary.swift b/MatrixSDK/Space/MXSpaceChildrenSummary.swift index 63d2d4de09..7e0a1ea1e7 100644 --- a/MatrixSDK/Space/MXSpaceChildrenSummary.swift +++ b/MatrixSDK/Space/MXSpaceChildrenSummary.swift @@ -22,16 +22,20 @@ public class MXSpaceChildrenSummary: NSObject { // MARK - Properties - /// The queried space room summary - public let spaceSummary: MXRoomSummary + /// The queried space room summary. Can be nil in case of batched request + public let spaceInfo: MXSpaceChildInfo? /// The child summaries of the queried space public let childInfos: [MXSpaceChildInfo] + /// The token to supply in the `from` param of the next request in order to request more rooms. If this is absent, there are no more results. + public let nextBatch: String? + // MARK - Setup - init(spaceSummary: MXRoomSummary, childInfos: [MXSpaceChildInfo]) { - self.spaceSummary = spaceSummary + init(spaceInfo: MXSpaceChildInfo?, childInfos: [MXSpaceChildInfo], nextBatch: String?) { + self.spaceInfo = spaceInfo self.childInfos = childInfos + self.nextBatch = nextBatch } } diff --git a/MatrixSDK/Space/MXSpaceService.swift b/MatrixSDK/Space/MXSpaceService.swift index ac90713b39..ca9cb1414c 100644 --- a/MatrixSDK/Space/MXSpaceService.swift +++ b/MatrixSDK/Space/MXSpaceService.swift @@ -262,14 +262,18 @@ public class MXSpaceService: NSObject { /// - spaceId: The room id of the queried space. /// - suggestedOnly: If `true`, return only child events and rooms where the `m.space.child` event has `suggested: true`. /// - limit: Optional. A limit to the maximum number of children to return per space. `-1` for no limit + /// - maxDepth: Optional. The maximum depth in the tree (from the root room) to return. `-1` for no limit + /// - paginationToken: Optional. Pagination token given to retrieve the next set of rooms. /// - completion: A closure called when the operation completes. /// - Returns: a `MXHTTPOperation` instance. @discardableResult public func getSpaceChildrenForSpace(withId spaceId: String, suggestedOnly: Bool, limit: Int?, + maxDepth: Int?, + paginationToken: String?, completion: @escaping (MXResponse) -> Void) -> MXHTTPOperation { - return self.session.matrixRestClient.getSpaceChildrenForSpace(withId: spaceId, suggestedOnly: suggestedOnly, limit: limit) { (response) in + return self.session.matrixRestClient.getSpaceChildrenForSpace(withId: spaceId, suggestedOnly: suggestedOnly, limit: limit, maxDepth: maxDepth, paginationToken: paginationToken) { (response) in switch response { case .success(let spaceChildrenResponse): self.processingQueue.async { [weak self] in @@ -285,39 +289,33 @@ public class MXSpaceService: NSObject { return } - guard let rootSpaceChildSummaryResponse = rooms.first(where: { spaceResponse -> Bool in - return spaceResponse.roomId == spaceId - }) else { - // Fail to find root child. We should have at least one room for the requested space - self.completionQueue.async { - completion(.failure(MXSpaceServiceError.spaceNotFound)) - } - return - } - - // Build the queried space summary - let spaceSummary = self.createRoomSummary(with: rootSpaceChildSummaryResponse) - // Build room hierarchy and events var childrenIdsPerChildRoomId: [String: [String]] = [:] var parentIdsPerChildRoomId: [String:Set] = [:] var spaceChildEventsPerChildRoomId: [String:[String:Any]] = [:] - for event in spaceChildrenResponse.events ?? [] where event.type == kMXEventTypeStringSpaceChild && event.wireContent.count > 0 { - spaceChildEventsPerChildRoomId[event.stateKey] = event.wireContent + for room in spaceChildrenResponse.rooms ?? [] { + for event in room.childrenState ?? [] where event.wireContent.count > 0 { + spaceChildEventsPerChildRoomId[event.stateKey] = event.wireContent - var parentIds = parentIdsPerChildRoomId[event.stateKey] ?? Set() - parentIds.insert(event.roomId) - parentIdsPerChildRoomId[event.stateKey] = parentIds + var parentIds = parentIdsPerChildRoomId[event.stateKey] ?? Set() + parentIds.insert(event.roomId) + parentIdsPerChildRoomId[event.stateKey] = parentIds - var childrenIds = childrenIdsPerChildRoomId[event.roomId] ?? [] - childrenIds.append(event.stateKey) - childrenIdsPerChildRoomId[event.roomId] = childrenIds + var childrenIds = childrenIdsPerChildRoomId[event.roomId] ?? [] + childrenIds.append(event.stateKey) + childrenIdsPerChildRoomId[event.roomId] = childrenIds + } + } + + var spaceInfo: MXSpaceChildInfo? + if let rootSpaceChildSummaryResponse = rooms.first(where: { spaceResponse -> Bool in spaceResponse.roomId == spaceId}) { + spaceInfo = self.createSpaceChildInfo(with: rootSpaceChildSummaryResponse, childrenIds: childrenIdsPerChildRoomId[spaceId], childEvents: spaceChildEventsPerChildRoomId[spaceId]) } // Build the child summaries of the queried space let childInfos = self.spaceChildInfos(from: spaceChildrenResponse, excludedSpaceId: spaceId, childrenIdsPerChildRoomId: childrenIdsPerChildRoomId, parentIdsPerChildRoomId: parentIdsPerChildRoomId, spaceChildEventsPerChildRoomId: spaceChildEventsPerChildRoomId) - let spaceChildrenSummary = MXSpaceChildrenSummary(spaceSummary: spaceSummary, childInfos: childInfos) + let spaceChildrenSummary = MXSpaceChildrenSummary(spaceInfo: spaceInfo, childInfos: childInfos, nextBatch: spaceChildrenResponse.nextBatch) self.completionQueue.async { completion(.success(spaceChildrenSummary)) @@ -716,23 +714,13 @@ public class MXSpaceService: NSObject { return nil } - let childStateEvent = spaceChildrenResponse.events?.first(where: { (event) -> Bool in - return event.stateKey == spaceId && event.eventType == .spaceChild - }) - - return self.createSpaceChildInfo(with: spaceChildSummaryResponse, and: childStateEvent, parentIds: parentIdsPerChildRoomId[spaceId], childrenIds: childrenIdsPerChildRoomId[spaceId], childEvents: spaceChildEventsPerChildRoomId[spaceId]) + return self.createSpaceChildInfo(with: spaceChildSummaryResponse, childrenIds: childrenIdsPerChildRoomId[spaceId], childEvents: spaceChildEventsPerChildRoomId[spaceId]) } return childInfos } - private func createSpaceChildInfo(with spaceChildSummaryResponse: MXSpaceChildSummaryResponse, and spaceChildStateEvent: MXEvent?, parentIds: Set?, childrenIds: [String]?, childEvents: [String:Any]?) -> MXSpaceChildInfo { - - var spaceChildContent: MXSpaceChildContent? - - if let stateEventContent = spaceChildStateEvent?.content { - spaceChildContent = MXSpaceChildContent(fromJSON: stateEventContent) - } + private func createSpaceChildInfo(with spaceChildSummaryResponse: MXSpaceChildSummaryResponse, childrenIds: [String]?, childEvents: [String:Any]?) -> MXSpaceChildInfo { let roomTypeString = spaceChildSummaryResponse.roomType let roomType = self.roomTypeMapper.roomType(from: roomTypeString) @@ -745,14 +733,10 @@ public class MXSpaceService: NSObject { topic: spaceChildSummaryResponse.topic, canonicalAlias: spaceChildSummaryResponse.canonicalAlias, avatarUrl: spaceChildSummaryResponse.avatarUrl, - order: spaceChildContent?.order, activeMemberCount: spaceChildSummaryResponse.numJoinedMembers, autoJoin: childEvents?[kMXEventTypeStringAutoJoinKey] as? Bool ?? false, suggested: childEvents?[kMXEventTypeStringSuggestedKey] as? Bool ?? false, - parentIds: parentIds ?? Set(), - childrenIds: childrenIds ?? [], - viaServers: spaceChildContent?.via ?? [], - parentRoomId: spaceChildStateEvent?.roomId) + childrenIds: childrenIds ?? []) } } @@ -792,12 +776,14 @@ extension MXSpaceService { /// - spaceId: The room id of the queried space. /// - suggestedOnly: If `true`, return only child events and rooms where the `m.space.child` event has `suggested: true`. /// - limit: Optional. A limit to the maximum number of children to return per space. `-1` for no limit + /// - maxDepth: Optional. The maximum depth in the tree (from the root room) to return. `-1` for no limit + /// - paginationToken: Optional. Pagination token given to retrieve the next set of rooms. /// - success: A closure called when the operation is complete. /// - failure: A closure called when the operation fails. /// - Returns: a `MXHTTPOperation` instance. @discardableResult - @objc public func getSpaceChildrenForSpace(withId spaceId: String, suggestedOnly: Bool, limit: Int, success: @escaping (MXSpaceChildrenSummary) -> Void, failure: @escaping (Error) -> Void) -> MXHTTPOperation { - return self.getSpaceChildrenForSpace(withId: spaceId, suggestedOnly: suggestedOnly, limit: limit) { (response) in + @objc public func getSpaceChildrenForSpace(withId spaceId: String, suggestedOnly: Bool, limit: Int, maxDepth: Int, paginationToken: String?, success: @escaping (MXSpaceChildrenSummary) -> Void, failure: @escaping (Error) -> Void) -> MXHTTPOperation { + return self.getSpaceChildrenForSpace(withId: spaceId, suggestedOnly: suggestedOnly, limit: limit, maxDepth: maxDepth, paginationToken: paginationToken) { (response) in uncurryResponse(response, success: success, failure: failure) } } diff --git a/MatrixSDKTests/MXSpaceServiceTest.swift b/MatrixSDKTests/MXSpaceServiceTest.swift index f16dc024e3..9ffb894e95 100644 --- a/MatrixSDKTests/MXSpaceServiceTest.swift +++ b/MatrixSDKTests/MXSpaceServiceTest.swift @@ -373,13 +373,13 @@ class MXSpaceServiceTest: XCTestCase { dispatchGroup.notify(queue: .main) { // Get space children of B node - spaceService.getSpaceChildrenForSpace(withId: spaceB.spaceId, suggestedOnly: false, limit: nil) { response in + spaceService.getSpaceChildrenForSpace(withId: spaceB.spaceId, suggestedOnly: false, limit: nil, maxDepth: nil, paginationToken: nil) { response in XCTAssertTrue(Thread.isMainThread) switch response { case .success(let spaceChildrenSummary): - XCTAssert(spaceChildrenSummary.spaceSummary.displayname == spaceB.summary?.displayname) + XCTAssert(spaceChildrenSummary.spaceInfo?.displayName == spaceB.summary?.displayname) let childInfos = spaceChildrenSummary.childInfos diff --git a/changelog.d/4893.feature b/changelog.d/4893.feature new file mode 100644 index 0000000000..6f4692d785 --- /dev/null +++ b/changelog.d/4893.feature @@ -0,0 +1 @@ +Moved from /space to /hierarchy API to support pagination \ No newline at end of file