From 839fdbfc4173bdab444d18a5dd52daaab25dd769 Mon Sep 17 00:00:00 2001 From: Hwee-Boon Yar Date: Thu, 17 May 2018 16:43:09 +0800 Subject: [PATCH] Fix: import ticket UI should not change to prompt for import again shortly after importing paid link --- Trust/Market/Coordinators/UniversalLinkCoordinator.swift | 3 +++ .../ViewModels/ImportTicketViewControllerViewModel.swift | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/Trust/Market/Coordinators/UniversalLinkCoordinator.swift b/Trust/Market/Coordinators/UniversalLinkCoordinator.swift index 5f69ee25e..aaa0c0a93 100644 --- a/Trust/Market/Coordinators/UniversalLinkCoordinator.swift +++ b/Trust/Market/Coordinators/UniversalLinkCoordinator.swift @@ -18,6 +18,7 @@ class UniversalLinkCoordinator: Coordinator { var importTicketViewController: ImportTicketViewController? var ethPrice: Subscribable? var ethBalance: Subscribable? + var hasCompleted = false func start() { @@ -246,6 +247,7 @@ class UniversalLinkCoordinator: Coordinator { } private func updateImportTicketController(with state: ImportTicketViewControllerViewModel.State, ticketHolder: TicketHolder? = nil, ethCost: String? = nil, dollarCost: String? = nil) { + guard !hasCompleted else { return } if let vc = importTicketViewController, var viewModel = vc.viewModel { viewModel.state = state if let ticketHolder = ticketHolder { @@ -259,6 +261,7 @@ class UniversalLinkCoordinator: Coordinator { } vc.configure(viewModel: viewModel) } + hasCompleted = state.hasCompleted } private func promptImportUniversalLink(ticketHolder: TicketHolder, ethCost: String, dollarCost: String? = nil) { diff --git a/Trust/Market/ViewModels/ImportTicketViewControllerViewModel.swift b/Trust/Market/ViewModels/ImportTicketViewControllerViewModel.swift index 3ef44e4b9..e7abdad4e 100644 --- a/Trust/Market/ViewModels/ImportTicketViewControllerViewModel.swift +++ b/Trust/Market/ViewModels/ImportTicketViewControllerViewModel.swift @@ -9,6 +9,15 @@ struct ImportTicketViewControllerViewModel { case processing case succeeded case failed(errorMessage: String) + + var hasCompleted: Bool { + switch self { + case .succeeded, .failed: + return true + case .validating, .processing, .promptImport: + return false + } + } } var state: State var ticketHolder: TicketHolder?