switching to slugs and probably some other stuff I did a month ago

parent 40d3b674
......@@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>74</string>
<string>44</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
......
......@@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>74</string>
<string>44</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
......
......@@ -40,7 +40,7 @@ class IntentViewController: UIViewController, INUIHostedViewControlling {
let model = results[0]
let facilities = model.facilities
let found = facilities.filter({(facility: WOPFacility) -> Bool in
return facility.facilityName == (facilityIntent!.facility?.identifier ?? "")
return facility.slug == (facilityIntent!.facility?.identifier ?? "")
})
if found.count > 0 {
let facility = found.first
......
......@@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>73</string>
<string>44</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>
......
......@@ -1821,6 +1821,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 55A0C09478B7DBC1FC75A8DC /* Pods-WhatsOpenKit.debug.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
......@@ -1857,6 +1858,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = CB841F0B185710285842956F /* Pods-WhatsOpenKit.release.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
......@@ -1892,6 +1894,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = E07255E2520C5F76ABB7A176 /* Pods-WhatsOpenKit.app store.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
......
......@@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
defaults.set("Apple Maps", forKey: "mapsApp")
}
application.setMinimumBackgroundFetchInterval(TimeInterval(exactly: 60)!)
application.setMinimumBackgroundFetchInterval(3600)
return true
}
......
......@@ -867,7 +867,7 @@
<image name="major" width="63.840000152587891" height="63.840000152587891"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="lwF-fe-hI5"/>
<segue reference="FRf-a6-Dgs"/>
</inferredMetricsTieBreakers>
<color key="tintColor" red="0.0" green="0.40000000000000002" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
</document>
......@@ -30,13 +30,15 @@ public class WOPFilters {
public func applyFiltersOnFacilities(_ facilities: List<WOPFacility>) -> List<WOPFacility> {
//TODO: Add checks for onlyFromLocations and onlyFromCategories here before doing the rest
let specifiedFacilities = List<WOPFacility>()
let specifiedFacilities = List<WOPFacility>()
// facility must be within both a specified location and category
for f in facilities {
if onlyFromLocations[(f.facilityLocation?.building)!.lowercased()] == true && onlyFromCategories[(f.category?.categoryName)!.lowercased()] == true {
specifiedFacilities.append(f)
}
}
// let filteredFacilities = facilities.filter({ self.onlyFromLocations[($0.facilityLocation?.building)!.lowercased()] ?? false && self.onlyFromCategories[($0.category?.categoryName)!.lowercased()] ?? false })
let (open, closed) = separateOpenAndClosed(specifiedFacilities)
......@@ -236,3 +238,6 @@ public extension List {
}
}
func filterByLocation(_ facilities: [WOPFacility], filters: WOPFilters) -> [WOPFacility] {
return facilities.filter { filters.onlyFromLocations[($0.facilityLocation?.building)!.lowercased()] ?? false }
}
......@@ -141,7 +141,7 @@ class DetailViewButtonsViewController: UIViewController, INUIAddVoiceShortcutVie
func setActivityUp() {
activity.isEligibleForHandoff = true
activity.isEligibleForSearch = true
activity.addUserInfoEntries(from: ["facility": facility.facilityName])
activity.addUserInfoEntries(from: ["facility": facility.slug])
activity.title = facility.facilityName
activity.keywords = Set<String>(arrayLiteral: facility.facilityName, facility.facilityLocation!.building)
//activity.keywords = [facility.facilityName, facility.facilityLocation?.building]
......
......@@ -169,16 +169,23 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
var goodToGo = false
@objc func toDetailFromSearch(_ notification: Notification) {
func toDetailCompletion() {
let storyboard = UIStoryboard(name: "WOPSharedUI", bundle: Bundle(for: WOPFacilityDetailViewController.self))
let dest = storyboard.instantiateViewController(withIdentifier: "detailView") as! WOPFacilityDetailViewController
let userActivity = notification.object as? NSUserActivity
if(userActivity == nil) {
return // don't do anything
}
let facility = realm.objects(WOPFacilitiesModel.self)[0].facilities.filter(NSPredicate(format: "facilityName = '" + (userActivity?.title)! + "'")).first
var facility = realm.objects(WOPFacilitiesModel.self)[0].facilities.filter(NSPredicate(format: "slug = \"" + (userActivity?.title)! + "\"")).first
if(facility == nil) {
return // don't do anything
facility = realm.objects(WOPFacilitiesModel.self)[0].facilities.filter(NSPredicate(format: "facilityName = \"" + (userActivity?.title)! + "\"")).first
if facility == nil {
return // don't do anything
}
}
let storyboard = UIStoryboard(name: "WOPSharedUI", bundle: Bundle(for: WOPFacilityDetailViewController.self))
let dest = storyboard.instantiateViewController(withIdentifier: "detailView") as! WOPFacilityDetailViewController
dest.facility = facility!
let detailViewWithButtons = self.storyboard?.instantiateViewController(withIdentifier: "detailViewButtons") as? DetailViewButtonsViewController
......@@ -212,12 +219,16 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
@objc func toDetailFromURL(_ notification: Notification) {
let facilityEncoded = notification.userInfo!["facility"] as? String
let facilityDecoded = facilityEncoded?.removingPercentEncoding
let facility = realm.objects(WOPFacilitiesModel.self)[0].facilities.filter(NSPredicate(format: "facilityName = \"" + (facilityDecoded)! + "\"")).first
var facility = realm.objects(WOPFacilitiesModel.self)[0].facilities.filter(NSPredicate(format: "slug = \"" + (facilityDecoded)! + "\"")).first
if(facility == nil) {
return // don't do anything
facility = realm.objects(WOPFacilitiesModel.self)[0].facilities.filter(NSPredicate(format: "facilityName = \"" + (facilityDecoded)! + "\"")).first
if facility == nil {
return // don't do anything
}
}
let dest = self.storyboard?.instantiateViewController(withIdentifier: "detailView") as! WOPFacilityDetailViewController
let storyboard = UIStoryboard(name: "WOPSharedUI", bundle: Bundle(for: WOPFacilityDetailViewController.self))
let dest = storyboard.instantiateViewController(withIdentifier: "detailView") as! WOPFacilityDetailViewController
dest.facility = facility!
let detailViewWithButtons = self.storyboard?.instantiateViewController(withIdentifier: "detailViewButtons") as? DetailViewButtonsViewController
......@@ -368,6 +379,9 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
}
filteredFacilities = filteredByCampus
//filteredFacilities = filteredFacilities.filter({ campusFilters![($0.facilityLocation?.campus.lowercased())!]! })
shownFacilities = filteredFacilities
favoritesControlChanges(self)
......@@ -422,24 +436,6 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
func filterFacilitiesForSearchText(_ searchText: String) -> List<WOPFacility> {
var filtered: List<WOPFacility>
/*
if showFavorites {
let favoriteFacilities = filterFacilitiesForFavorites()
if searchText == "" { // if the search text is empty, just return the favorites.
filtered = favoriteFacilities
} else {
filtered = favoriteFacilities.filter({(facility: Facility) -> Bool in
let hasName = facility.facilityName.lowercased().contains(searchText.lowercased())
let hasBuilding = facility.facilityLocation?.building.lowercased().contains(searchText.lowercased()) ?? false
let hasCategory = facility.category?.categoryName.lowercased().contains(searchText.lowercased()) ?? false
return hasName || hasBuilding || hasCategory
})
}
} else {
*/
if searchText == "" {
filtered = shownFacilities
LocationsList.reloadData()
......@@ -694,13 +690,6 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
if (indexPath.section == 1 || currentAlerts.count == 0) {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionCell", for: indexPath) as! FacilityCollectionViewCell
/*
let windowRect = self.view.window!.frame
let windowWidth = windowRect.size.width
if(windowWidth <= 320) {
cell.frame.size.width = 280
}
*/
//Get tap of the cell
cell.tapRecognizer.addTarget(self, action: #selector(FacilitiesListViewController.tapRecognizer(_:)))
cell.gestureRecognizers = []
......@@ -708,18 +697,6 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
let facility: WOPFacility
//let dataArray: [Facility]
/*
// if something has been searched for, we want to use the filtered array as the data source
if isSearching() || showFavorites {
dataArray = placeOpenFacilitiesFirstInArray(filteredFacilities)
} else {
dataArray = placeOpenFacilitiesFirstInArray(facilitiesArray)
}
*/
facility = shownFacilities[indexPath.row]
......@@ -956,7 +933,8 @@ class FacilitiesListViewController: UIViewController, UICollectionViewDelegate,
guard let indexPath = LocationsList?.indexPathForItem(at: location) else { return nil }
if(indexPath.section == 1 || currentAlerts.count == 0) {
let cell = LocationsList?.cellForItem(at: indexPath) as? FacilityCollectionViewCell
guard let detailView = storyboard?.instantiateViewController(withIdentifier: "detailView") as? WOPFacilityDetailViewController else { return nil }
let storyboard = UIStoryboard(name: "WOPSharedUI", bundle: Bundle(for: WOPFacilityDetailViewController.self))
guard let detailView = storyboard.instantiateViewController(withIdentifier: "detailView") as? WOPFacilityDetailViewController else { return nil }
detailView.facility = cell?.facility
return detailView
}
......
......@@ -55,7 +55,7 @@ public class WOPFacility: Object, MapContext, Mappable {
public func createIntent() -> WOPViewFacilityIntent {
let viewFacilityIntent = WOPViewFacilityIntent()
viewFacilityIntent.facility = INObject(identifier: self.facilityName, display: self.facilityName)
viewFacilityIntent.facility = INObject(identifier: self.slug, display: self.facilityName)
viewFacilityIntent.name = self.facilityName
viewFacilityIntent.suggestedInvocationPhrase = "Is \(facilityName) open?"
......
......@@ -20,11 +20,10 @@ public class WOPViewFacilityIntentHandler: NSObject, WOPViewFacilityIntentHandli
let model = results[0]
let facilities = model.facilities
let found = facilities.filter({(facility: WOPFacility) -> Bool in
return facility.facilityName == (intent.facility?.identifier ?? "")
return facility.slug == (intent.facility?.identifier ?? "")
})
if found.count > 0 {
let activity = NSUserActivity(activityType: "facilityIntent")
activity.isEligibleForHandoff = true
activity.isEligibleForSearch = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment