Browse Source

Better onboarding!

pull/101/head
Abhishek 3 years ago
parent
commit
aa0259f33d
  1. 11
      Clocker/Onboarding/OnboardingSearchController.swift
  2. 4
      Clocker/Preferences/General/SearchDataSource.swift

11
Clocker/Onboarding/OnboardingSearchController.swift

@ -84,8 +84,9 @@ class OnboardingSearchController: NSViewController {
let selectedType = searchResultsDataSource.placeForRow(resultsTableView.selectedRow)
switch selectedType {
case .city:
let filteredGoogleResult = searchResultsDataSource.retrieveFilteredResultFromGoogleAPI(resultsTableView.selectedRow)
addTimezoneToDefaults(filteredGoogleResult!)
if let filteredGoogleResult = searchResultsDataSource.retrieveFilteredResultFromGoogleAPI(resultsTableView.selectedRow) {
addTimezoneToDefaults(filteredGoogleResult)
}
return
case .timezone:
cleanupAfterInstallingTimezone()
@ -422,6 +423,8 @@ class OnboardingSearchController: NSViewController {
private func resetSearchView() {
searchResultsDataSource.cleanupFilterArray()
searchResultsDataSource.timezoneFilteredArray = []
searchResultsDataSource.calculateChangesets()
resultsTableView.reloadData()
searchBar.stringValue = CLEmptyString
searchBar.placeholderString = "Press Enter to Search"
@ -513,4 +516,8 @@ extension OnboardingSearchController: NSSearchFieldDelegate {
// return true if the action was handled; otherwise false
return false
}
func searchFieldDidEndSearching(_ sender: NSSearchField) {
self.search(sender)
}
}

4
Clocker/Preferences/General/SearchDataSource.swift

@ -75,6 +75,10 @@ class SearchDataSource: NSObject {
}
func retrieveFilteredResultFromGoogleAPI(_ index: Int) -> TimezoneData? {
if index >= filteredArray.count {
return nil
}
return filteredArray[index % filteredArray.count]
}

Loading…
Cancel
Save