SP3.1: Update room settings for Spaces #5231

- Update after review
This commit is contained in:
Gil Eluard
2022-02-28 16:07:09 +01:00
parent bbff0a5c6f
commit c84285955b
52 changed files with 878 additions and 519 deletions
@@ -26,10 +26,10 @@ class MatrixItemChooserRoomAncestorsDataSource: MatrixItemChooserDataSource {
}
func sections(with session: MXSession, completion: @escaping (Result<[MatrixListItemSectionData], Error>) -> Void) {
let ancestorsId = session.spaceService.ancestorsPerRoomId[roomId] ?? []
let ancestorsIds = session.spaceService.ancestorsPerRoomId[roomId] ?? []
completion(Result(catching: {
return [
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsId.compactMap { spaceId in
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsIds.compactMap { spaceId in
guard let space = session.spaceService.getSpace(withId: spaceId) else {
return nil
}
@@ -34,7 +34,7 @@ class MatrixItemChooserRoomDirectParentsDataSource: MatrixItemChooserDataSource
}
func sections(with session: MXSession, completion: @escaping (Result<[MatrixListItemSectionData], Error>) -> Void) {
let ancestorsId = session.spaceService.directParentIds(ofRoomWithId: roomId)
let ancestorsIds = session.spaceService.directParentIds(ofRoomWithId: roomId)
switch preselectionMode {
case .none:
@@ -45,7 +45,7 @@ class MatrixItemChooserRoomDirectParentsDataSource: MatrixItemChooserDataSource
completion(Result(catching: {
return [
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsId.compactMap { spaceId in
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), infoText: nil, items: ancestorsIds.compactMap { spaceId in
guard let space = session.spaceService.getSpace(withId: spaceId) else {
return nil
}
@@ -37,7 +37,7 @@ class MatrixItemChooserRoomRestrictedAllowedParentsDataSource: MatrixItemChooser
guard let self = self else { return }
let joinRuleEvent = state?.stateEvents(with: .roomJoinRules)?.last
let allowContent: [[String:String]] = joinRuleEvent?.wireContent["allow"] as? [[String:String]] ?? []
let allowContent: [[String: String]] = joinRuleEvent?.wireContent["allow"] as? [[String: String]] ?? []
self.allowedParentIds = allowContent.compactMap { allowDictionnary in
guard let type = allowDictionnary["type"], type == "m.room_membership" else {
return nil
@@ -23,13 +23,13 @@ extension MatrixListItemData {
}
init(mxRoom: MXRoom, spaceService: MXSpaceService) {
let parentSapceIds = mxRoom.summary.parentSpaceIds ?? Set()
let parentSpaceIds = mxRoom.summary.parentSpaceIds ?? Set()
let detailText: String?
if parentSapceIds.isEmpty {
if parentSpaceIds.isEmpty {
detailText = nil
} else {
if let spaceName = spaceService.getSpace(withId: parentSapceIds.first ?? "")?.summary?.displayname {
let count = parentSapceIds.count - 1
if let spaceName = spaceService.getSpace(withId: parentSpaceIds.first ?? "")?.summary?.displayname {
let count = parentSpaceIds.count - 1
switch count {
case 0:
detailText = VectorL10n.spacesCreationInSpacename(spaceName)
@@ -39,8 +39,8 @@ extension MatrixListItemData {
detailText = VectorL10n.spacesCreationInSpacenamePlusMany(spaceName, "\(count)")
}
} else {
if parentSapceIds.count > 1 {
detailText = VectorL10n.spacesCreationInManySpaces("\(parentSapceIds.count)")
if parentSpaceIds.count > 1 {
detailText = VectorL10n.spacesCreationInManySpaces("\(parentSpaceIds.count)")
} else {
detailText = VectorL10n.spacesCreationInOneSpace
}