mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
Only display unencrypted rooms which we can use with the chat view.
This commit is contained in:
@@ -68,9 +68,11 @@ struct TemplateRoomChat: View {
|
||||
.accessibility(identifier: "loadingProgress")
|
||||
} else if case .failedToInitialize = viewModel.viewState.roomInitializationStatus {
|
||||
Text("Sorry, We failed to load the room.")
|
||||
.foregroundColor(theme.colors.primaryContent)
|
||||
.accessibility(identifier: "errorMessage")
|
||||
} else if viewModel.viewState.bubbles.isEmpty {
|
||||
Text("There are no messages in this room yet.")
|
||||
.foregroundColor(theme.colors.primaryContent)
|
||||
.accessibility(identifier: "errorMessage")
|
||||
} else {
|
||||
bubbleList
|
||||
|
||||
@@ -34,7 +34,11 @@ class TemplateRoomListService: TemplateRoomListServiceProtocol {
|
||||
|
||||
init(session: MXSession) {
|
||||
self.session = session
|
||||
self.roomsSubject = CurrentValueSubject(session.rooms.map(TemplateRoomListRoom.init(mxRoom:)))
|
||||
|
||||
let unencryptedRooms = session.rooms
|
||||
.filter(\.summary.isEncrypted)
|
||||
.map(TemplateRoomListRoom.init(mxRoom:))
|
||||
self.roomsSubject = CurrentValueSubject(unencryptedRooms)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ struct TemplateRoomList: View {
|
||||
|
||||
var body: some View {
|
||||
listContent
|
||||
.navigationTitle("Rooms")
|
||||
.navigationTitle("Unencrypted Rooms")
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .primaryAction) {
|
||||
Button(VectorL10n.done) {
|
||||
@@ -45,6 +45,7 @@ struct TemplateRoomList: View {
|
||||
var listContent: some View {
|
||||
if viewModel.viewState.rooms.isEmpty {
|
||||
Text("No Rooms")
|
||||
.foregroundColor(theme.colors.primaryContent)
|
||||
.accessibility(identifier: "errorMessage")
|
||||
} else {
|
||||
ScrollView{
|
||||
|
||||
@@ -38,22 +38,21 @@ class TemplateRoomListViewModel: TemplateRoomListViewModelType, TemplateRoomList
|
||||
|
||||
init(templateRoomListService: TemplateRoomListServiceProtocol) {
|
||||
self.templateRoomListService = templateRoomListService
|
||||
|
||||
super.init(initialViewState: Self.defaultState(templateRoomListService: templateRoomListService))
|
||||
|
||||
templateRoomListService.roomsSubject
|
||||
.map(TemplateRoomListStateAction.updateRooms)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink(receiveValue: { [weak self] action in
|
||||
self?.dispatch(action:action)
|
||||
})
|
||||
.store(in: &cancellables)
|
||||
startObservingRooms()
|
||||
}
|
||||
|
||||
private static func defaultState(templateRoomListService: TemplateRoomListServiceProtocol) -> TemplateRoomListViewState {
|
||||
return TemplateRoomListViewState(rooms: templateRoomListService.roomsSubject.value)
|
||||
}
|
||||
|
||||
private func startObservingRooms() {
|
||||
let roomsUpdatePublisher = templateRoomListService.roomsSubject
|
||||
.map(TemplateRoomListStateAction.updateRooms)
|
||||
.eraseToAnyPublisher()
|
||||
dispatch(actionPublisher: roomsUpdatePublisher)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
override func process(viewAction: TemplateRoomListViewAction) {
|
||||
|
||||
Reference in New Issue
Block a user