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) let selectedType = searchResultsDataSource.placeForRow(resultsTableView.selectedRow)
switch selectedType { switch selectedType {
case .city: case .city:
let filteredGoogleResult = searchResultsDataSource.retrieveFilteredResultFromGoogleAPI(resultsTableView.selectedRow) if let filteredGoogleResult = searchResultsDataSource.retrieveFilteredResultFromGoogleAPI(resultsTableView.selectedRow) {
addTimezoneToDefaults(filteredGoogleResult!) addTimezoneToDefaults(filteredGoogleResult)
}
return return
case .timezone: case .timezone:
cleanupAfterInstallingTimezone() cleanupAfterInstallingTimezone()
@ -422,6 +423,8 @@ class OnboardingSearchController: NSViewController {
private func resetSearchView() { private func resetSearchView() {
searchResultsDataSource.cleanupFilterArray() searchResultsDataSource.cleanupFilterArray()
searchResultsDataSource.timezoneFilteredArray = []
searchResultsDataSource.calculateChangesets()
resultsTableView.reloadData() resultsTableView.reloadData()
searchBar.stringValue = CLEmptyString searchBar.stringValue = CLEmptyString
searchBar.placeholderString = "Press Enter to Search" searchBar.placeholderString = "Press Enter to Search"
@ -513,4 +516,8 @@ extension OnboardingSearchController: NSSearchFieldDelegate {
// return true if the action was handled; otherwise false // return true if the action was handled; otherwise false
return 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? { func retrieveFilteredResultFromGoogleAPI(_ index: Int) -> TimezoneData? {
if index >= filteredArray.count {
return nil
}
return filteredArray[index % filteredArray.count] return filteredArray[index % filteredArray.count]
} }

Loading…
Cancel
Save