From 48e6988ff39490971ab403ce41ae9a51715944a8 Mon Sep 17 00:00:00 2001 From: lazarog98 <lazarog98@ninlil.imp.fu-berlin.de> Date: Tue, 3 Mar 2020 10:44:37 +0100 Subject: [PATCH] #238 remove ios version checks --- enzevalos_iphone/InboxViewController.swift | 24 +++++++++++++--------- enzevalos_iphone/ListViewController.swift | 14 ++++++------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/enzevalos_iphone/InboxViewController.swift b/enzevalos_iphone/InboxViewController.swift index f61f2722..8dbf2624 100644 --- a/enzevalos_iphone/InboxViewController.swift +++ b/enzevalos_iphone/InboxViewController.swift @@ -253,18 +253,22 @@ class InboxViewController: UITableViewController, InboxCellDelegator { return searchController.isActive && !searchBarIsEmpty } - /// searches a given string with a delay so that the entire client doesn't lag if the inbox is very big - // TODO: Perhaps think of a better name + /** + searches a given string with a delay so that the entire client doesn't lag if the inbox is very big + + - parameters: + - searchText: srtring to look for + - scope: where to search (look at _filterContentForSearchText) + */ func startSearch(searchText: String, scope: Int = 0) { - if #available(iOS 10.0, *) { - if let searchBarTimer: Timer = self.searchBarTimer { - searchBarTimer.invalidate() - } - - self.searchBarTimer = Timer.scheduledTimer(withTimeInterval: searchDelay, repeats: false, block: { _ in - self._filterContentForSearchText(searchText, scope: scope) - }) + // check if a search has been scheduled already and stop it to prevent multiple searches + if let searchBarTimer: Timer = self.searchBarTimer { + searchBarTimer.invalidate() } + + self.searchBarTimer = Timer.scheduledTimer(withTimeInterval: searchDelay, repeats: false, block: { _ in + self._filterContentForSearchText(searchText, scope: scope) + }) } /** diff --git a/enzevalos_iphone/ListViewController.swift b/enzevalos_iphone/ListViewController.swift index d6fcb37a..4983b0bc 100644 --- a/enzevalos_iphone/ListViewController.swift +++ b/enzevalos_iphone/ListViewController.swift @@ -110,14 +110,14 @@ class ListViewController: UITableViewController { } func startSearch(searchText: String, scope: Int = 0) { - if #available(iOS 10.0, *) { - if let searchBarTimer: Timer = self.searchTimer { - searchBarTimer.invalidate() - } - self.searchTimer = Timer.scheduledTimer(withTimeInterval: searchDelay, repeats: false, block: { _ in - self.filterContentForSearchText(searchText, scope: scope) - }) + // check if a search has been scheduled already and stop it to prevent multiple searches + if let searchBarTimer: Timer = self.searchTimer { + searchBarTimer.invalidate() } + + self.searchTimer = Timer.scheduledTimer(withTimeInterval: searchDelay, repeats: false, block: { _ in + self.filterContentForSearchText(searchText, scope: scope) + }) } /** -- GitLab