From 6ef643e3746aafd3f999c41a66a218e85e4d3a85 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 31 Dec 2019 11:45:34 -0500 Subject: [PATCH] Fix custom instances not showing up when typed into the instance selector search field With Combine Cancellables are automatically cancelled on deinit, so the instance selector needs to hold on to a reference to pipeline cancellable for its lifetime, otherwise it's cancelled immediately after creation. Closes #59 --- .../Onboarding/InstanceSelectorTableViewController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tusker/Screens/Onboarding/InstanceSelectorTableViewController.swift b/Tusker/Screens/Onboarding/InstanceSelectorTableViewController.swift index 572e2b2f22..9d48ca6f12 100644 --- a/Tusker/Screens/Onboarding/InstanceSelectorTableViewController.swift +++ b/Tusker/Screens/Onboarding/InstanceSelectorTableViewController.swift @@ -26,6 +26,7 @@ class InstanceSelectorTableViewController: UITableViewController { var recommendedInstances: [InstanceSelector.Instance] = [] let urlCheckerSubject = PassthroughSubject() + var urlHandler: AnyCancellable? var currentQuery: String? init() { @@ -66,7 +67,7 @@ class InstanceSelectorTableViewController: UITableViewController { navigationItem.searchController = searchController definesPresentationContext = true - _ = urlCheckerSubject + urlHandler = urlCheckerSubject .debounce(for: .seconds(1), scheduler: RunLoop.main) .compactMap { $0?.trimmingCharacters(in: .whitespacesAndNewlines) } .sink(receiveValue: updateSpecificInstance)