mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Be more lenient with the power levels as they can still be missing at the time the various screens are created e.g. after accepting an invite.
The correct solution is to subscribe to update and update the UI accordingly when receiving them.
This commit is contained in:
committed by
Stefan Ceriu
parent
37cbf733d4
commit
9c28a69ccf
@@ -23,18 +23,14 @@ class ThreadTimelineScreenViewModel: ThreadTimelineScreenViewModelType, ThreadTi
|
||||
|
||||
super.init(initialViewState: ThreadTimelineScreenViewState())
|
||||
|
||||
Task { [weak self] in
|
||||
for await roomInfo in roomProxy.infoPublisher.receive(on: DispatchQueue.main).values {
|
||||
guard !Task.isCancelled else {
|
||||
return
|
||||
}
|
||||
|
||||
self?.handleRoomInfoUpdate(roomInfo)
|
||||
roomProxy.infoPublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] roomInfo in
|
||||
self?.updateRoomInfo(roomInfo)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
.store(in: &cancellables)
|
||||
|
||||
handleRoomInfoUpdate(roomProxy.infoPublisher.value)
|
||||
updateRoomInfo(roomProxy.infoPublisher.value)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
@@ -62,8 +58,9 @@ class ThreadTimelineScreenViewModel: ThreadTimelineScreenViewModelType, ThreadTi
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func handleRoomInfoUpdate(_ roomInfo: RoomInfoProxyProtocol) {
|
||||
guard let powerLevels = roomInfo.powerLevels else { fatalError("Missing room power levels") }
|
||||
state.canSendMessage = powerLevels.canOwnUser(sendMessage: .roomMessage)
|
||||
private func updateRoomInfo(_ roomInfo: RoomInfoProxyProtocol) {
|
||||
if let powerLevels = roomInfo.powerLevels {
|
||||
state.canSendMessage = powerLevels.canOwnUser(sendMessage: .roomMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user