mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-19 16:13:42 +02:00
Configured and applied SwiftFormat
This commit is contained in:
committed by
Stefan Ceriu
parent
ff2e6ddfa7
commit
43c28d23b7
+3
-4
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,7 +17,6 @@
|
||||
import Foundation
|
||||
|
||||
class MatrixItemChooserDirectChildrenDataSource: MatrixItemChooserDataSource {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private let parentId: String
|
||||
@@ -34,13 +33,13 @@ class MatrixItemChooserDirectChildrenDataSource: MatrixItemChooserDataSource {
|
||||
|
||||
func sections(with session: MXSession, completion: @escaping (Result<[MatrixListItemSectionData], Error>) -> Void) {
|
||||
let space = session.spaceService.getSpace(withId: parentId)
|
||||
let children: [MatrixListItemData] = space?.childRoomIds.compactMap({ roomId in
|
||||
let children: [MatrixListItemData] = space?.childRoomIds.compactMap { roomId in
|
||||
guard let room = session.room(withRoomId: roomId), !room.isDirect else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return MatrixListItemData(mxRoom: room, spaceService: session.spaceService)
|
||||
}) ?? []
|
||||
} ?? []
|
||||
completion(Result(catching: {
|
||||
[
|
||||
MatrixListItemSectionData(items: children)
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -28,7 +28,7 @@ class MatrixItemChooserRoomAncestorsDataSource: MatrixItemChooserDataSource {
|
||||
func sections(with session: MXSession, completion: @escaping (Result<[MatrixListItemSectionData], Error>) -> Void) {
|
||||
let ancestorsIds = session.spaceService.ancestorsPerRoomId[roomId] ?? []
|
||||
completion(Result(catching: {
|
||||
return [
|
||||
[
|
||||
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), items: ancestorsIds.compactMap { spaceId in
|
||||
guard let space = session.spaceService.getSpace(withId: spaceId) else {
|
||||
return nil
|
||||
|
||||
+1
-2
@@ -22,7 +22,6 @@ enum MatrixItemChooserRoomDirectParentsDataSourcePreselectionMode {
|
||||
}
|
||||
|
||||
class MatrixItemChooserRoomDirectParentsDataSource: MatrixItemChooserDataSource {
|
||||
|
||||
private let roomId: String
|
||||
private let preselectionMode: MatrixItemChooserRoomDirectParentsDataSourcePreselectionMode
|
||||
|
||||
@@ -44,7 +43,7 @@ class MatrixItemChooserRoomDirectParentsDataSource: MatrixItemChooserDataSource
|
||||
}
|
||||
|
||||
completion(Result(catching: {
|
||||
return [
|
||||
[
|
||||
MatrixListItemSectionData(title: VectorL10n.roomAccessSpaceChooserKnownSpacesSection(session.room(withRoomId: roomId)?.displayName ?? ""), items: ancestorsIds.compactMap { spaceId in
|
||||
guard let space = session.spaceService.getSpace(withId: spaceId) else {
|
||||
return nil
|
||||
|
||||
+7
-6
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -34,7 +34,7 @@ class MatrixItemChooserRoomRestrictedAllowedParentsDataSource: MatrixItemChooser
|
||||
}
|
||||
|
||||
room.state { [weak self] state in
|
||||
guard let self = self else { return }
|
||||
guard let self = self else { return }
|
||||
|
||||
let joinRuleEvent = state?.stateEvents(with: .roomJoinRules)?.last
|
||||
let allowContent: [[String: String]] = joinRuleEvent?.wireContent[kMXJoinRulesContentKeyAllow] as? [[String: String]] ?? []
|
||||
@@ -74,19 +74,20 @@ class MatrixItemChooserRoomRestrictedAllowedParentsDataSource: MatrixItemChooser
|
||||
sections.append(MatrixListItemSectionData(
|
||||
title: VectorL10n.roomAccessSpaceChooserOtherSpacesSection,
|
||||
infoText: VectorL10n.roomAccessSpaceChooserOtherSpacesSectionInfo(room.displayName ?? ""),
|
||||
items: unknownParents.compactMap({ roomId in
|
||||
items: unknownParents.compactMap { roomId in
|
||||
MatrixListItemData(
|
||||
id: roomId,
|
||||
type: .space,
|
||||
avatar: AvatarInput(mxContentUri: roomId, matrixItemId: roomId, displayName: roomId),
|
||||
displayName: roomId,
|
||||
detailText: nil)
|
||||
})
|
||||
detailText: nil
|
||||
)
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
completion(Result(catching: {
|
||||
return sections
|
||||
sections
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
+14
-12
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
protocol MatrixItemChooserDataSource {
|
||||
func sections(with session: MXSession, completion: @escaping (Result<[MatrixListItemSectionData], Error>) -> Void)
|
||||
@@ -25,12 +25,11 @@ protocol MatrixItemChooserDataSource {
|
||||
protocol MatrixItemChooserProcessorProtocol {
|
||||
var loadingText: String? { get }
|
||||
var dataSource: MatrixItemChooserDataSource { get }
|
||||
func computeSelection(withIds itemsIds:[String], completion: @escaping (Result<Void, Error>) -> Void)
|
||||
func isItemIncluded(_ item: (MatrixListItemData)) -> Bool
|
||||
func computeSelection(withIds itemsIds: [String], completion: @escaping (Result<Void, Error>) -> Void)
|
||||
func isItemIncluded(_ item: MatrixListItemData) -> Bool
|
||||
}
|
||||
|
||||
class MatrixItemChooserService: MatrixItemChooserServiceProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
@@ -45,6 +44,7 @@ class MatrixItemChooserService: MatrixItemChooserServiceProtocol {
|
||||
sectionsSubject.send(filteredSections)
|
||||
}
|
||||
}
|
||||
|
||||
private var selectedItemIds: Set<String>
|
||||
private let itemsProcessor: MatrixItemChooserProcessorProtocol
|
||||
|
||||
@@ -52,14 +52,16 @@ class MatrixItemChooserService: MatrixItemChooserServiceProtocol {
|
||||
|
||||
private(set) var sectionsSubject: CurrentValueSubject<[MatrixListItemSectionData], Never>
|
||||
private(set) var selectedItemIdsSubject: CurrentValueSubject<Set<String>, Never>
|
||||
var searchText: String = "" {
|
||||
var searchText = "" {
|
||||
didSet {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
var loadingText: String? {
|
||||
itemsProcessor.loadingText
|
||||
}
|
||||
|
||||
var itemCount: Int {
|
||||
var itemCount = 0
|
||||
for section in sections {
|
||||
@@ -72,10 +74,10 @@ class MatrixItemChooserService: MatrixItemChooserServiceProtocol {
|
||||
|
||||
init(session: MXSession, selectedItemIds: [String], itemsProcessor: MatrixItemChooserProcessorProtocol) {
|
||||
self.session = session
|
||||
self.sectionsSubject = CurrentValueSubject(self.sections)
|
||||
sectionsSubject = CurrentValueSubject(sections)
|
||||
|
||||
self.selectedItemIds = Set(selectedItemIds)
|
||||
self.selectedItemIdsSubject = CurrentValueSubject(self.selectedItemIds)
|
||||
selectedItemIdsSubject = CurrentValueSubject(self.selectedItemIds)
|
||||
self.itemsProcessor = itemsProcessor
|
||||
|
||||
itemsProcessor.dataSource.sections(with: session) { [weak self] result in
|
||||
@@ -115,7 +117,7 @@ class MatrixItemChooserService: MatrixItemChooserServiceProtocol {
|
||||
}
|
||||
|
||||
func refresh() {
|
||||
self.processingQueue.async { [weak self] in
|
||||
processingQueue.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
let filteredSections = self.filter(sections: self.sections)
|
||||
|
||||
@@ -132,12 +134,12 @@ class MatrixItemChooserService: MatrixItemChooserServiceProtocol {
|
||||
newSelection.insert(item.id)
|
||||
}
|
||||
}
|
||||
self.selectedItemIds = newSelection
|
||||
selectedItemIds = newSelection
|
||||
selectedItemIdsSubject.send(selectedItemIds)
|
||||
}
|
||||
|
||||
func deselectAllItems() {
|
||||
self.selectedItemIds = Set()
|
||||
selectedItemIds = Set()
|
||||
selectedItemIdsSubject.send(selectedItemIds)
|
||||
}
|
||||
|
||||
@@ -153,7 +155,7 @@ class MatrixItemChooserService: MatrixItemChooserServiceProtocol {
|
||||
itemsProcessor.isItemIncluded($0)
|
||||
}
|
||||
} else {
|
||||
let lowercasedSearchText = self.searchText.lowercased()
|
||||
let lowercasedSearchText = searchText.lowercased()
|
||||
items = section.items.filter {
|
||||
itemsProcessor.isItemIncluded($0) && ($0.id.lowercased().contains(lowercasedSearchText) || ($0.displayName ?? "").lowercased().contains(lowercasedSearchText))
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
+1
-3
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,7 +17,6 @@
|
||||
import Foundation
|
||||
|
||||
extension MatrixListItemData {
|
||||
|
||||
init(mxUser: MXUser) {
|
||||
self.init(id: mxUser.userId, type: .user, avatar: mxUser.avatarData, displayName: mxUser.displayname, detailText: mxUser.userId)
|
||||
}
|
||||
@@ -54,5 +53,4 @@ extension MatrixListItemData {
|
||||
}
|
||||
self.init(id: mxRoom.roomId, type: type, avatar: mxRoom.avatarData, displayName: mxRoom.summary.displayname, detailText: detailText)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user