Fixes #2147 - Scroll the timeline to the bottom when sending message as well as media, polls and locations.

This commit is contained in:
Stefan Ceriu
2023-12-04 15:55:28 +02:00
committed by Stefan Ceriu
parent 6905ac5f70
commit 8189b0a471
9 changed files with 92 additions and 31 deletions
@@ -279,7 +279,8 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
.store(in: &cancellables)
roomProxy
.stateUpdatesPublisher
.actions
.filter { $0 == .stateUpdate }
.throttle(for: .seconds(1), scheduler: DispatchQueue.main, latest: true)
.sink { [weak self] _ in
guard let self else { return }
@@ -288,6 +289,14 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
self.state.hasOngoingCall = roomProxy.hasOngoingCall
}
.store(in: &cancellables)
roomProxy.timeline.actions
.filter { $0 == .sentMessage }
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
self?.state.timelineViewState.scrollToBottomPublisher.send(())
}
.store(in: &cancellables)
appSettings.$timelineStyle
.weakAssign(to: \.state.timelineStyle, on: self)
@@ -468,8 +477,6 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
case .recordVoiceMessage, .previewVoiceMessage:
fatalError("invalid composer mode.")
}
state.timelineViewState.scrollToBottomPublisher.send(())
}
private func trackComposerMode(_ mode: RoomScreenComposerMode) {