mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Disable the threaded timeline composer when the room is read only.
This commit is contained in:
committed by
Stefan Ceriu
parent
9804be70eb
commit
c3a9e5deaa
@@ -11,13 +11,32 @@ import SwiftUI
|
||||
typealias ThreadTimelineScreenViewModelType = StateStoreViewModel<ThreadTimelineScreenViewState, ThreadTimelineScreenViewAction>
|
||||
|
||||
class ThreadTimelineScreenViewModel: ThreadTimelineScreenViewModelType, ThreadTimelineScreenViewModelProtocol {
|
||||
private let roomProxy: JoinedRoomProxyProtocol
|
||||
|
||||
private let actionsSubject: PassthroughSubject<ThreadTimelineScreenViewModelAction, Never> = .init()
|
||||
var actionsPublisher: AnyPublisher<ThreadTimelineScreenViewModelAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
init(roomProxy: JoinedRoomProxyProtocol) {
|
||||
self.roomProxy = roomProxy
|
||||
|
||||
super.init(initialViewState: ThreadTimelineScreenViewState())
|
||||
|
||||
Task { [weak self] in
|
||||
for await roomInfo in roomProxy.infoPublisher.receive(on: DispatchQueue.main).values {
|
||||
guard !Task.isCancelled else {
|
||||
return
|
||||
}
|
||||
|
||||
await self?.handleRoomInfoUpdate(roomInfo)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
Task {
|
||||
await handleRoomInfoUpdate(roomProxy.infoPublisher.value)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -42,4 +61,10 @@ class ThreadTimelineScreenViewModel: ThreadTimelineScreenViewModelType, ThreadTi
|
||||
|
||||
state.bindings.mediaPreviewViewModel = mediaPreviewViewModel
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func handleRoomInfoUpdate(_ roomInfo: RoomInfoProxy) async {
|
||||
state.canSendMessage = await (try? roomProxy.canUser(userID: roomProxy.ownUserID, sendMessage: .roomMessage).get()) == true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user