From c8cda2ee7b540a3fcdf1774c333868e72a04c96e Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 19 Oct 2019 11:49:44 -0700 Subject: [PATCH] Restricting API calls to start after every 3rd call. --- .../ban.xcuserdatad/xcschemes/xcschememanagement.plist | 2 +- Clocker/Clocker/ca.lproj/Localizable.strings | 2 +- Clocker/Clocker/de.lproj/Localizable.strings | 2 +- Clocker/Clocker/en.lproj/Localizable.strings | 2 +- Clocker/Clocker/es.lproj/Localizable.strings | 2 +- Clocker/Clocker/fr.lproj/Localizable.strings | 2 +- Clocker/Clocker/hi.lproj/Localizable.strings | 2 +- Clocker/Clocker/ja.lproj/Localizable.strings | 2 +- Clocker/Clocker/ko.lproj/Localizable.strings | 2 +- Clocker/Clocker/nl.lproj/Localizable.strings | 2 +- Clocker/Clocker/ru.lproj/Localizable.strings | 2 +- Clocker/Clocker/zh-Hans.lproj/Localizable.strings | 2 +- Clocker/Dependencies/Date Additions/Date+Comparators.swift | 2 +- Clocker/Dependencies/Date Additions/TimePeriodGroup.swift | 4 ++-- Clocker/Onboarding/OnboardingSearchController.swift | 6 +++++- 15 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Clocker/Clocker.xcodeproj/xcuserdata/ban.xcuserdatad/xcschemes/xcschememanagement.plist b/Clocker/Clocker.xcodeproj/xcuserdata/ban.xcuserdatad/xcschemes/xcschememanagement.plist index b07b414..0fc8a42 100644 --- a/Clocker/Clocker.xcodeproj/xcuserdata/ban.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Clocker/Clocker.xcodeproj/xcuserdata/ban.xcuserdatad/xcschemes/xcschememanagement.plist @@ -17,7 +17,7 @@ Tests.xcscheme_^#shared#^_ orderHint - 3 + 1 SuppressBuildableAutocreation diff --git a/Clocker/Clocker/ca.lproj/Localizable.strings b/Clocker/Clocker/ca.lproj/Localizable.strings index 8788d9d..101a685 100644 --- a/Clocker/Clocker/ca.lproj/Localizable.strings +++ b/Clocker/Clocker/ca.lproj/Localizable.strings @@ -84,7 +84,7 @@ // Onboarding Search "Quick Add Locations" = "Quick Add Locations"; "More search options in Clocker Preferences." = "More search options in Clocker Preferences."; -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; // Start at Login "Launch at Login" = "Launch at Login"; diff --git a/Clocker/Clocker/de.lproj/Localizable.strings b/Clocker/Clocker/de.lproj/Localizable.strings index df1a520..a54d25a 100644 --- a/Clocker/Clocker/de.lproj/Localizable.strings +++ b/Clocker/Clocker/de.lproj/Localizable.strings @@ -235,7 +235,7 @@ "Search Field Placeholder" = "Enter a city, state or country name"; /* (No Comment) */ -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; /* Next Event Label for no Calendar access */ "See your next Calendar event here." = "See your next Calendar event here."; diff --git a/Clocker/Clocker/en.lproj/Localizable.strings b/Clocker/Clocker/en.lproj/Localizable.strings index 8788d9d..101a685 100644 --- a/Clocker/Clocker/en.lproj/Localizable.strings +++ b/Clocker/Clocker/en.lproj/Localizable.strings @@ -84,7 +84,7 @@ // Onboarding Search "Quick Add Locations" = "Quick Add Locations"; "More search options in Clocker Preferences." = "More search options in Clocker Preferences."; -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; // Start at Login "Launch at Login" = "Launch at Login"; diff --git a/Clocker/Clocker/es.lproj/Localizable.strings b/Clocker/Clocker/es.lproj/Localizable.strings index 8788d9d..101a685 100644 --- a/Clocker/Clocker/es.lproj/Localizable.strings +++ b/Clocker/Clocker/es.lproj/Localizable.strings @@ -84,7 +84,7 @@ // Onboarding Search "Quick Add Locations" = "Quick Add Locations"; "More search options in Clocker Preferences." = "More search options in Clocker Preferences."; -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; // Start at Login "Launch at Login" = "Launch at Login"; diff --git a/Clocker/Clocker/fr.lproj/Localizable.strings b/Clocker/Clocker/fr.lproj/Localizable.strings index 8788d9d..101a685 100644 --- a/Clocker/Clocker/fr.lproj/Localizable.strings +++ b/Clocker/Clocker/fr.lproj/Localizable.strings @@ -84,7 +84,7 @@ // Onboarding Search "Quick Add Locations" = "Quick Add Locations"; "More search options in Clocker Preferences." = "More search options in Clocker Preferences."; -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; // Start at Login "Launch at Login" = "Launch at Login"; diff --git a/Clocker/Clocker/hi.lproj/Localizable.strings b/Clocker/Clocker/hi.lproj/Localizable.strings index a8ff086..fc5cb44 100644 --- a/Clocker/Clocker/hi.lproj/Localizable.strings +++ b/Clocker/Clocker/hi.lproj/Localizable.strings @@ -80,7 +80,7 @@ // Onboarding Search "Quick Add Locations" = "Quick Add Locations"; "More search options in Clocker Preferences." = "More search options in Clocker Preferences."; -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; // Start at Login "Launch at Login" = "Launch at Login"; diff --git a/Clocker/Clocker/ja.lproj/Localizable.strings b/Clocker/Clocker/ja.lproj/Localizable.strings index 07af75b..ae89694 100644 --- a/Clocker/Clocker/ja.lproj/Localizable.strings +++ b/Clocker/Clocker/ja.lproj/Localizable.strings @@ -83,7 +83,7 @@ // Onboarding Search "Quick Add Locations" = "Quick Add Locations"; "More search options in Clocker Preferences." = "More search options in Clocker Preferences."; -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; // Start at Login "Launch at Login" = "Launch at Login"; diff --git a/Clocker/Clocker/ko.lproj/Localizable.strings b/Clocker/Clocker/ko.lproj/Localizable.strings index 07af75b..ae89694 100644 --- a/Clocker/Clocker/ko.lproj/Localizable.strings +++ b/Clocker/Clocker/ko.lproj/Localizable.strings @@ -83,7 +83,7 @@ // Onboarding Search "Quick Add Locations" = "Quick Add Locations"; "More search options in Clocker Preferences." = "More search options in Clocker Preferences."; -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; // Start at Login "Launch at Login" = "Launch at Login"; diff --git a/Clocker/Clocker/nl.lproj/Localizable.strings b/Clocker/Clocker/nl.lproj/Localizable.strings index 8788d9d..101a685 100644 --- a/Clocker/Clocker/nl.lproj/Localizable.strings +++ b/Clocker/Clocker/nl.lproj/Localizable.strings @@ -84,7 +84,7 @@ // Onboarding Search "Quick Add Locations" = "Quick Add Locations"; "More search options in Clocker Preferences." = "More search options in Clocker Preferences."; -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; // Start at Login "Launch at Login" = "Launch at Login"; diff --git a/Clocker/Clocker/ru.lproj/Localizable.strings b/Clocker/Clocker/ru.lproj/Localizable.strings index 5630702..75ef1c2 100644 --- a/Clocker/Clocker/ru.lproj/Localizable.strings +++ b/Clocker/Clocker/ru.lproj/Localizable.strings @@ -235,7 +235,7 @@ "Search Field Placeholder" = "Enter a city, state or country name"; /* (No Comment) */ -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; /* Next Event Label for no Calendar access */ "See your next Calendar event here." = "See your next Calendar event here."; diff --git a/Clocker/Clocker/zh-Hans.lproj/Localizable.strings b/Clocker/Clocker/zh-Hans.lproj/Localizable.strings index 84acced..b09c24c 100644 --- a/Clocker/Clocker/zh-Hans.lproj/Localizable.strings +++ b/Clocker/Clocker/zh-Hans.lproj/Localizable.strings @@ -235,7 +235,7 @@ "Search Field Placeholder" = "Enter a city, state or country name"; /* (No Comment) */ -"Search Locations" = "Search Locations"; +"Enter 3 or more characters for locations you'll like to add" = "Enter 3 or more characters for locations you'll like to add"; /* Next Event Label for no Calendar access */ "See your next Calendar event here." = "See your next Calendar event here."; diff --git a/Clocker/Dependencies/Date Additions/Date+Comparators.swift b/Clocker/Dependencies/Date Additions/Date+Comparators.swift index b358221..8553c69 100755 --- a/Clocker/Dependencies/Date Additions/Date+Comparators.swift +++ b/Clocker/Dependencies/Date Additions/Date+Comparators.swift @@ -43,7 +43,7 @@ public extension Date { * - returns: A TimeChunk representing the time between the dates, in natural form */ func chunkBetween(date: Date) -> TimeChunk { - var compenentsBetween = Calendar.autoupdatingCurrent.dateComponents([.year, .month, .day, .hour, .minute, .second], from: self, to: date) + let compenentsBetween = Calendar.autoupdatingCurrent.dateComponents([.year, .month, .day, .hour, .minute, .second], from: self, to: date) return TimeChunk(seconds: compenentsBetween.second!, minutes: compenentsBetween.minute!, hours: compenentsBetween.hour!, days: compenentsBetween.day!, weeks: 0, months: compenentsBetween.month!, years: compenentsBetween.year!) // TimeChunk(seconds: secondDelta, minutes: minuteDelta, hours: hourDelta, days: dayDelta, weeks: 0, months: monthDelta, years: yearDelta) } diff --git a/Clocker/Dependencies/Date Additions/TimePeriodGroup.swift b/Clocker/Dependencies/Date Additions/TimePeriodGroup.swift index 4980706..27a40c1 100755 --- a/Clocker/Dependencies/Date Additions/TimePeriodGroup.swift +++ b/Clocker/Dependencies/Date Additions/TimePeriodGroup.swift @@ -114,7 +114,7 @@ open class TimePeriodGroup: Sequence { return false // No need to sorting if they already have different counts } - var compArray1: [TimePeriodProtocol] = array1.sorted { (period1: TimePeriodProtocol, period2: TimePeriodProtocol) -> Bool in + let compArray1: [TimePeriodProtocol] = array1.sorted { (period1: TimePeriodProtocol, period2: TimePeriodProtocol) -> Bool in if period1.beginning == nil, period2.beginning == nil { return false } else if period1.beginning == nil { @@ -125,7 +125,7 @@ open class TimePeriodGroup: Sequence { return period2.beginning! < period1.beginning! } } - var compArray2: [TimePeriodProtocol] = array2.sorted { (period1: TimePeriodProtocol, period2: TimePeriodProtocol) -> Bool in + let compArray2: [TimePeriodProtocol] = array2.sorted { (period1: TimePeriodProtocol, period2: TimePeriodProtocol) -> Bool in if period1.beginning == nil, period2.beginning == nil { return false } else if period1.beginning == nil { diff --git a/Clocker/Onboarding/OnboardingSearchController.swift b/Clocker/Onboarding/OnboardingSearchController.swift index 553a549..7e3b45a 100644 --- a/Clocker/Onboarding/OnboardingSearchController.swift +++ b/Clocker/Onboarding/OnboardingSearchController.swift @@ -211,7 +211,7 @@ class OnboardingSearchController: NSViewController { appName.stringValue = "Quick Add Locations".localized() onboardingTypeLabel.stringValue = "More search options in Clocker Preferences.".localized() setInfoLabel(CLEmptyString) - searchBar.placeholderString = "Search Locations".localized() + searchBar.placeholderString = "Enter 3 or more characters for locations you'll like to add".localized() resultsTableView.backgroundColor = Themer.shared().mainBackgroundColor() resultsTableView.enclosingScrollView?.backgroundColor = Themer.shared().mainBackgroundColor() @@ -259,6 +259,10 @@ class OnboardingSearchController: NSViewController { searchString = words.joined(separator: CLEmptyString) + if searchString.count < 3 { + return + } + let urlString = "https://maps.googleapis.com/maps/api/geocode/json?address=\(searchString)&key=\(CLGeocodingKey)&language=\(userPreferredLanguage)" dataTask = NetworkManager.task(with: urlString,