mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 00:24:43 +02:00
App Layout: added space invites in space bottom sheet
This commit is contained in:
+41
-10
@@ -31,21 +31,45 @@ class SpaceSelectorService: SpaceSelectorServiceProtocol {
|
||||
private var spaceList: [SpaceSelectorListItemData] {
|
||||
let notificationCounter = session.spaceService.notificationCounter
|
||||
|
||||
let childSpaces: [SpaceSelectorListItemData]
|
||||
var invitedSpaces: [SpaceSelectorListItemData] = []
|
||||
var joinedSpaces: [SpaceSelectorListItemData] = []
|
||||
if let parentSpaceId = parentSpaceId, let parentSpace = session.spaceService.getSpace(withId: parentSpaceId) {
|
||||
childSpaces = parentSpace.childSpaces.compactMap { space in
|
||||
SpaceSelectorListItemData.itemData(with: space, notificationCounter: notificationCounter)
|
||||
for space in parentSpace.childSpaces {
|
||||
guard let item = SpaceSelectorListItemData.itemData(with: space, notificationCounter: notificationCounter) else {
|
||||
continue
|
||||
}
|
||||
|
||||
if item.isJoined {
|
||||
joinedSpaces.append(item)
|
||||
} else {
|
||||
invitedSpaces.append(item)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
childSpaces = session.spaceService.rootSpaces.compactMap { space in
|
||||
SpaceSelectorListItemData.itemData(with: space, notificationCounter: notificationCounter)
|
||||
for space in session.spaceService.rootSpaces {
|
||||
guard let item = SpaceSelectorListItemData.itemData(with: space, notificationCounter: notificationCounter) else {
|
||||
continue
|
||||
}
|
||||
|
||||
if item.isJoined {
|
||||
joinedSpaces.append(item)
|
||||
} else {
|
||||
invitedSpaces.append(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guard !invitedSpaces.isEmpty || !joinedSpaces.isEmpty else {
|
||||
return []
|
||||
}
|
||||
|
||||
var itemList: [SpaceSelectorListItemData] = []
|
||||
itemList.append(contentsOf: invitedSpaces)
|
||||
if showHomeSpace && parentSpaceId == nil {
|
||||
itemList.append(SpaceSelectorListItemData(id: SpaceSelectorConstants.homeSpaceId, icon: Asset.Images.sideMenuActionIconFeedback.image, displayName: VectorL10n.allChatsTitle, isJoined: true))
|
||||
}
|
||||
itemList.append(contentsOf: joinedSpaces)
|
||||
|
||||
var itemList = showHomeSpace && parentSpaceId == nil && !childSpaces.isEmpty ? [SpaceSelectorListItemData(id: SpaceSelectorConstants.homeSpaceId, icon: Asset.Images.sideMenuActionIconFeedback.image, displayName: VectorL10n.allChatsTitle)] : []
|
||||
|
||||
itemList.append(contentsOf: childSpaces)
|
||||
|
||||
return itemList
|
||||
}
|
||||
|
||||
@@ -75,6 +99,12 @@ class SpaceSelectorService: SpaceSelectorServiceProtocol {
|
||||
|
||||
spaceListSubject.send(spaceList)
|
||||
parentSpaceNameSubject.send(parentSpaceName)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.spaceServiceDidUpdate), name: MXSpaceService.didBuildSpaceGraph, object: nil)
|
||||
}
|
||||
|
||||
@objc private func spaceServiceDidUpdate() {
|
||||
spaceListSubject.send(spaceList)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +121,7 @@ fileprivate extension SpaceSelectorListItemData {
|
||||
displayName: summary.displayname,
|
||||
notificationCount: notificationState?.groupMissedDiscussionsCount ?? 0,
|
||||
highlightedNotificationCount: notificationState?.groupMissedDiscussionsHighlightedCount ?? 0,
|
||||
hasSubItems: !space.childSpaces.isEmpty)
|
||||
hasSubItems: !space.childSpaces.isEmpty,
|
||||
isJoined: summary.isJoined)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user