diff --git a/Adamant/Modules/Chat/View/ChatViewController.swift b/Adamant/Modules/Chat/View/ChatViewController.swift index c18674202..428913cce 100644 --- a/Adamant/Modules/Chat/View/ChatViewController.swift +++ b/Adamant/Modules/Chat/View/ChatViewController.swift @@ -136,6 +136,7 @@ final class ChatViewController: MessagesViewController { setupObservers() viewModel.loadFirstMessagesIfNeeded() chatSwipeManager.configure(chatView: view) + checkNodesEnabled() } override func viewWillLayoutSubviews() { @@ -161,7 +162,6 @@ final class ChatViewController: MessagesViewController { defer { viewAppeared = true } inputBar.isUserInteractionEnabled = true chatMessagesCollectionView.fixedBottomOffset = nil - checkNodesEnabled() if !viewAppeared { viewModel.presentKeyboardOnStartIfNeeded() @@ -786,11 +786,9 @@ private extension ChatViewController { func checkNodesEnabled() { guard viewModel.hasEnabledNode else { - viewModel.dialog.send(.showNodesListAlertAction({ [weak self] in - guard let self else { return } - let vc = screensFactory.makeNodesList() - navigationController?.pushViewController(vc, animated: true) - })) + if let navigationController { + viewModel.dialog.send(.showNodesListAlertAction(navigationController, screensFactory)) + } return } } diff --git a/Adamant/Modules/Chat/View/Managers/ChatDialogManager.swift b/Adamant/Modules/Chat/View/Managers/ChatDialogManager.swift index 60feffc57..4488838eb 100644 --- a/Adamant/Modules/Chat/View/Managers/ChatDialogManager.swift +++ b/Adamant/Modules/Chat/View/Managers/ChatDialogManager.swift @@ -72,8 +72,8 @@ private extension ChatDialogManager { showMenu(sender: sender) case .freeTokenAlert: showFreeTokenAlert() - case .showNodesListAlertAction(let showAction): - showNodeListAlert(showAction: showAction) + case .showNodesListAlertAction(let navigation, let screenFactory): + showNodeListAlertAction(navigation, screenFactory) case let .removeMessageAlert(id): showRemoveMessageAlert(id: id) case let .reportMessageAlert(id): @@ -201,7 +201,7 @@ private extension ChatDialogManager { dialogService.present(alert, animated: true, completion: nil) } - func showNodeListAlert(showAction: @escaping () -> Void) { + func showNodeListAlertAction(_ navigation: UINavigationController,_ factory: ScreensFactory) { let alert = UIAlertController( title: String.adamant.chat.admNoActiveNodesTitle, message: String.adamant.chat.admNoActiveNodes, @@ -212,7 +212,8 @@ private extension ChatDialogManager { alert.modalPresentationStyle = .overFullScreen let cancelAction = UIAlertAction(title: String.adamant.alert.cancel, style: .default) let showListAction = UIAlertAction(title: String.adamant.alert.reviewNodeList, style: .default) { _ in - showAction() + let vc = factory.makeNodesList() + navigation.pushViewController(vc, animated: true) } alert.addAction(showListAction) diff --git a/Adamant/Modules/Chat/ViewModel/Models/ChatDialog.swift b/Adamant/Modules/Chat/ViewModel/Models/ChatDialog.swift index 911b01bd5..f217f6e55 100644 --- a/Adamant/Modules/Chat/ViewModel/Models/ChatDialog.swift +++ b/Adamant/Modules/Chat/ViewModel/Models/ChatDialog.swift @@ -17,7 +17,7 @@ enum ChatDialog { case warning(String) case richError(Error) case freeTokenAlert - case showNodesListAlertAction(() -> Void) + case showNodesListAlertAction(UINavigationController, ScreensFactory) case removeMessageAlert(id: String) case reportMessageAlert(id: String) case menu(sender: UIBarButtonItem)