Browse Source

Update PreferencesViewController.swift

pull/92/head
Abhishek 4 years ago
parent
commit
95df24857d
  1. 18
      Clocker/Preferences/General/PreferencesViewController.swift

18
Clocker/Preferences/General/PreferencesViewController.swift

@ -466,16 +466,8 @@ extension PreferencesViewController {
} }
private func findLocalSearchResultsForTimezones() { private func findLocalSearchResultsForTimezones() {
searchResultsDataSource.timezoneFilteredArray = []
let lowercasedSearchString = searchField.stringValue.lowercased() let lowercasedSearchString = searchField.stringValue.lowercased()
searchResultsDataSource.searchTimezones(lowercasedSearchString)
searchResultsDataSource.timezoneFilteredArray = searchResultsDataSource.timezoneArray.filter { (timezoneMetadata) -> Bool in
let tags = timezoneMetadata.tags
for tag in tags where tag.contains(lowercasedSearchString) {
return true
}
return false
}
Logger.info(searchResultsDataSource.timezoneFilteredArray.debugDescription) Logger.info(searchResultsDataSource.timezoneFilteredArray.debugDescription)
} }
@ -613,7 +605,7 @@ extension PreferencesViewController {
} }
private func installTimezone(_ timezone: Timezone) { private func installTimezone(_ timezone: Timezone) {
guard let dataObject = searchResultsDataSource.filteredArray[availableTimezoneTableView.selectedRow % searchResultsDataSource.filteredArray.count] as? TimezoneData else { guard let dataObject = searchResultsDataSource.retrieveFilteredResult(availableTimezoneTableView.selectedRow) else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return return
} }
@ -763,7 +755,7 @@ extension PreferencesViewController {
} }
private func cleanupAfterInstallingCity() { private func cleanupAfterInstallingCity() {
guard let dataObject = searchResultsDataSource.filteredArray[availableTimezoneTableView.selectedRow % searchResultsDataSource.filteredArray.count] as? TimezoneData else { guard let dataObject = searchResultsDataSource.retrieveFilteredResult(availableTimezoneTableView.selectedRow) else {
assertionFailure("Data was unexpectedly nil") assertionFailure("Data was unexpectedly nil")
return return
} }
@ -784,8 +776,8 @@ extension PreferencesViewController {
let data = TimezoneData() let data = TimezoneData()
data.setLabel(CLEmptyString) data.setLabel(CLEmptyString)
let currentSelection = searchField.stringValue.isEmpty == false ? searchResultsDataSource.timezoneFilteredArray[availableTimezoneTableView.selectedRow % searchResultsDataSource.timezoneFilteredArray.count] : let currentSelection = searchResultsDataSource.retrieveSelectedTimezone(searchField.stringValue,
searchResultsDataSource.timezoneArray[availableTimezoneTableView.selectedRow - 1] availableTimezoneTableView.selectedRow)
let metaInfo = metadata(for: currentSelection) let metaInfo = metadata(for: currentSelection)
data.timezoneID = metaInfo.0.name data.timezoneID = metaInfo.0.name

Loading…
Cancel
Save