Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces: Add support for spaces Summary API #1072

Merged
merged 22 commits into from
Apr 21, 2021
Merged

Conversation

SBiOSoftWhare
Copy link
Contributor

@SBiOSoftWhare SBiOSoftWhare commented Apr 15, 2021

/// - completion: A closure called when the operation completes. Provides the event id of the event generated on the home server on success.
/// - Returns: a `MXHTTPOperation` instance.
@discardableResult
public func addChildWithDefaultViaServer(spaceId: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not remove this method to limit methods number and duplicated code? This will improve readiness and future maintenance.

Having an optional viaServers in the previous method will fulfil the behavior of this method.

import Foundation

/// MXSpaceChildInfo represents space child summary informations.
@objcMembers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: do we need usage from objc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this class will soon be exposed from MXRoomSummary


if (spaceChildSummaryResponse)
{
MXJSONModelSetString(spaceChildSummaryResponse.roomId, JSONDictionary[@"room_id"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should return nil if there is no roomId else we do not respect non_null in the header.

return self.session.matrixRestClient.getSpaceChildrenForSpace(withId: spaceId, parameters: parameters) { (response) in
switch response {
case .success(let spaceChildrenResponse):
guard let rooms = spaceChildrenResponse.rooms else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a processing queue?
I heard that we can expect crazy spaces hierarchies.

roomSummary.roomTypeString = roomTypeString
roomSummary.roomType = self.roomTypeMapper.roomType(from: roomTypeString)

let membersCount = MXRoomMembersCount()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about MXRoomMembersCount.members and MXRoomMembersCount.invited?
We should have members >= joined.


case .failure(let error):
XCTFail("Add child space failed with error \(error)")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expectation.fulfill()

if spaces.count == spaceNames.count {
completion(.success(spaces))
} else {
XCTFail("Fail to create spaces")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should return an error to avoid blocking the test suite. See other comments in this file.


expectation.fulfill()
case .failure(let error):
XCTFail("Get space children failed with error \(error)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expectation.fulfill()

@@ -169,4 +202,179 @@ class MXSpaceServiceTest: XCTestCase {
}
}
}

/// - Create Bob
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you report these comments in the code?
This is absolutely boring but it is even more boring to understand what a test does when you need to debug it afterwards.

}
}

/// - Create Bob
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

report these comments in the code

if (spaceChildSummaryResponse)
MXJSONModelSetString(roomId, JSONDictionary[@"room_id"]);

if (spaceChildSummaryResponse && roomId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should return nil if there is no roomId else we can have a non valid MXSpaceChildSummaryResponse instance at runtime.

public func addChild(spaceId: String,
viaServers: [String],
public func addChild(roomId: String,
viaServers: [String]?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if can have nil as default value. We are in full swift here, no?

let childSpace = spaces[1]

// Add space A as child of space B
rootSpace.addChild(roomId: childSpace.spaceId, viaServers: nil, order: nil, autoJoin: false, suggested: false) { (response) in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have default params values, we can do some cleaning ;)

@SBiOSoftWhare SBiOSoftWhare merged commit ade9357 into spaces Apr 21, 2021
@SBiOSoftWhare SBiOSoftWhare deleted the space_summary branch April 21, 2021 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants