mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 20:39:24 +00:00
Fix #4837 - Make sure changing the screen mode in the bindings also updates the activeTimelineContext
The original viewState mapping just stopped working properly for some reason. Updating it to `observe()` on `StateStoreViewModelV2` worked properly but I liked the viewAction based solution better, felt more streamlined.
This commit is contained in:
committed by
Stefan Ceriu
parent
0e33480928
commit
b71e667e73
+6
-12
@@ -54,18 +54,7 @@ class MediaEventsTimelineScreenViewModel: MediaEventsTimelineScreenViewModelType
|
||||
}
|
||||
|
||||
super.init(initialViewState: .init(activeTimelineContext: activeTimelineContext, bindings: .init(screenMode: initialScreenMode)), mediaProvider: mediaProvider)
|
||||
|
||||
context.$viewState.map(\.bindings.screenMode)
|
||||
.removeDuplicates()
|
||||
.map {
|
||||
switch $0 {
|
||||
case .media: mediaTimelineViewModel.context
|
||||
case .files: filesTimelineViewModel.context
|
||||
}
|
||||
}
|
||||
.weakAssign(to: \.state.activeTimelineContext, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
|
||||
mediaTimelineViewModel.context.$viewState.sink { [weak self] timelineViewState in
|
||||
guard let self, state.bindings.screenMode == .media else {
|
||||
return
|
||||
@@ -126,6 +115,11 @@ class MediaEventsTimelineScreenViewModel: MediaEventsTimelineScreenViewModelType
|
||||
|
||||
switch viewAction {
|
||||
case .changedScreenMode:
|
||||
switch state.bindings.screenMode {
|
||||
case .media: state.activeTimelineContext = mediaTimelineViewModel.context
|
||||
case .files: state.activeTimelineContext = filesTimelineViewModel.context
|
||||
}
|
||||
|
||||
updateWithTimelineViewState(activeTimelineViewModel.context.viewState)
|
||||
case .oldestItemDidAppear:
|
||||
isOldestItemVisible = true
|
||||
|
||||
Reference in New Issue
Block a user