Skip to content

Commit

Permalink
Better onboarding!
Browse files Browse the repository at this point in the history
  • Loading branch information
n0shake committed Jul 21, 2021
1 parent 0f6107e commit aa0259f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Clocker/Onboarding/OnboardingSearchController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 changes: 4 additions & 0 deletions Clocker/Preferences/General/SearchDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class SearchDataSource: NSObject {
}

func retrieveFilteredResultFromGoogleAPI(_ index: Int) -> TimezoneData? {
if index >= filteredArray.count {
return nil
}

return filteredArray[index % filteredArray.count]
}

Expand Down

0 comments on commit aa0259f

Please sign in to comment.