@@ -8,6 +8,7 @@ import Yosemite
88///
99final class CustomerSelectorViewController : UIViewController , GhostableViewController {
1010 private var searchViewController : SearchViewController < UnderlineableTitleAndSubtitleAndDetailTableViewCell , CustomerSearchUICommand > ?
11+ private var customerSearchCommand : CustomerSearchUICommand ?
1112 private var emptyStateViewController : UIViewController ?
1213 private let siteID : Int64
1314 private let onCustomerSelected : ( Customer ) -> Void
@@ -200,31 +201,34 @@ private extension CustomerSelectorViewController {
200201 shouldTrackCustomerAdded: Bool ,
201202 disallowCreatingCustomer: Bool ,
202203 onAddCustomerDetailsManually: ( ( ) -> Void ) ? = nil ) {
204+ let command = CustomerSearchUICommand ( siteID: siteID,
205+ loadResultsWhenSearchTermIsEmpty: loadResultsWhenSearchTermIsEmpty,
206+ showSearchFilters: showSearchFilters,
207+ showGuestLabel: showGuestLabel,
208+ shouldTrackCustomerAdded: shouldTrackCustomerAdded,
209+ disallowCreatingCustomer: disallowCreatingCustomer,
210+ hideDetailText: configuration. hideDetailText,
211+ selectedCustomerID: selectedCustomerID,
212+ onAddCustomerDetailsManually: onAddCustomerDetailsManually,
213+ onDidSelectSearchResult: onCustomerTapped,
214+ onDidStartSyncingAllCustomersFirstPage: {
215+ Task { @MainActor [ weak self] in
216+ guard let searchTableView = self ? . searchViewController? . tableView else {
217+ return
218+ }
219+ self ? . displayGhostContent ( over: searchTableView)
220+ }
221+ } ,
222+ onDidFinishSyncingAllCustomersFirstPage: {
223+ Task { @MainActor [ weak self] in
224+ self ? . removeGhostContent ( )
225+ }
226+ } )
227+ self . customerSearchCommand = command
228+
203229 let searchViewController = SearchViewController (
204230 storeID: siteID,
205- command: CustomerSearchUICommand ( siteID: siteID,
206- loadResultsWhenSearchTermIsEmpty: loadResultsWhenSearchTermIsEmpty,
207- showSearchFilters: showSearchFilters,
208- showGuestLabel: showGuestLabel,
209- shouldTrackCustomerAdded: shouldTrackCustomerAdded,
210- disallowCreatingCustomer: disallowCreatingCustomer,
211- hideDetailText: configuration. hideDetailText,
212- selectedCustomerID: selectedCustomerID,
213- onAddCustomerDetailsManually: onAddCustomerDetailsManually,
214- onDidSelectSearchResult: onCustomerTapped,
215- onDidStartSyncingAllCustomersFirstPage: {
216- Task { @MainActor [ weak self] in
217- guard let searchTableView = self ? . searchViewController? . tableView else {
218- return
219- }
220- self ? . displayGhostContent ( over: searchTableView)
221- }
222- } ,
223- onDidFinishSyncingAllCustomersFirstPage: {
224- Task { @MainActor [ weak self] in
225- self ? . removeGhostContent ( )
226- }
227- } ) ,
231+ command: command,
228232 cellType: UnderlineableTitleAndSubtitleAndDetailTableViewCell . self,
229233 cellSeparator: . none
230234 )
@@ -283,6 +287,8 @@ private extension CustomerSelectorViewController {
283287 viewModel. onCustomerSelected ( customer, onCompletion: { [ weak self] result in
284288 guard let self else { return }
285289 activityIndicator. stopAnimating ( )
290+ customerSearchCommand? . updateSelectedCustomerID ( customer. customerID)
291+ searchViewController? . tableView. reloadData ( )
286292
287293 switch result {
288294 case . success:
0 commit comments