Skip to content

Commit

Permalink
trello.com/c/F7EV0pKq changing presenting logic
Browse files Browse the repository at this point in the history
  • Loading branch information
leonid174 committed Jan 20, 2025
1 parent ed5d294 commit c241da5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
10 changes: 4 additions & 6 deletions Adamant/Modules/Chat/View/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ final class ChatViewController: MessagesViewController {
setupObservers()
viewModel.loadFirstMessagesIfNeeded()
chatSwipeManager.configure(chatView: view)
checkNodesEnabled()
}

override func viewWillLayoutSubviews() {
Expand All @@ -161,7 +162,6 @@ final class ChatViewController: MessagesViewController {
defer { viewAppeared = true }
inputBar.isUserInteractionEnabled = true
chatMessagesCollectionView.fixedBottomOffset = nil
checkNodesEnabled()

if !viewAppeared {
viewModel.presentKeyboardOnStartIfNeeded()
Expand Down Expand Up @@ -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
}
}
Expand Down
9 changes: 5 additions & 4 deletions Adamant/Modules/Chat/View/Managers/ChatDialogManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Adamant/Modules/Chat/ViewModel/Models/ChatDialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c241da5

Please sign in to comment.