mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Workaround the NavigationController not releasing popped screens and clean up the roomScreen + timelineController + timelineProvider + roomProxy on stop()
This commit is contained in:
committed by
Stefan Ceriu
parent
8c86bf9acb
commit
623eecec77
@@ -25,10 +25,16 @@ struct RoomScreenCoordinatorParameters {
|
||||
}
|
||||
|
||||
final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
private let parameters: RoomScreenCoordinatorParameters
|
||||
private var parameters: RoomScreenCoordinatorParameters?
|
||||
|
||||
private var viewModel: RoomScreenViewModelProtocol
|
||||
private var navigationController: NavigationController { parameters.navigationController }
|
||||
private var viewModel: RoomScreenViewModelProtocol?
|
||||
private var navigationController: NavigationController {
|
||||
guard let parameters else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
return parameters.navigationController
|
||||
}
|
||||
|
||||
init(parameters: RoomScreenCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
@@ -43,7 +49,7 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
// MARK: - Public
|
||||
|
||||
func start() {
|
||||
viewModel.callback = { [weak self] result in
|
||||
viewModel?.callback = { [weak self] result in
|
||||
guard let self else { return }
|
||||
MXLog.debug("RoomScreenViewModel did complete with result: \(result).")
|
||||
switch result {
|
||||
@@ -56,11 +62,17 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
|
||||
}
|
||||
|
||||
func stop() {
|
||||
viewModel.stop()
|
||||
viewModel?.stop()
|
||||
viewModel = nil
|
||||
parameters = nil
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(RoomScreen(context: viewModel.context))
|
||||
guard let context = viewModel?.context else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
return AnyView(RoomScreen(context: context))
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
@@ -57,7 +57,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
|
||||
slidingSyncViewProxy.diffPublisher
|
||||
.collect(.byTime(serialDispatchQueue, 0.25))
|
||||
.sink { self.updateRoomsWithDiffs($0) }
|
||||
.sink { [weak self] in self?.updateRoomsWithDiffs($0) }
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class RoomTimelineProvider: RoomTimelineProviderProtocol {
|
||||
roomTimelineListener
|
||||
.itemsUpdatePublisher
|
||||
.collect(.byTime(serialDispatchQueue, 0.25))
|
||||
.sink { self.updateItemsWithDiffs($0) }
|
||||
.sink { [weak self] in self?.updateItemsWithDiffs($0) }
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user