Skip to content

Commit

Permalink
Merge pull request #443 from pennlabs/dining-analytics-refresh-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JHawk0224 authored Dec 4, 2022
2 parents 290fcaa + 1ec9472 commit 82d089f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion PennMobile/Dining/SwiftUI/DiningAnalyticsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ struct DiningAnalyticsView: View {
showMissingDiningTokenAlert = true
return
}
await diningAnalyticsViewModel.refresh(refreshWidgets: true)
}
.alert(isPresented: $showMissingDiningTokenAlert) {
showCorrectAlert()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ extension String {
func capitalizeFirstLetter() -> String {
return self.prefix(1).capitalized + self.dropFirst()
}
// Used for splitting string by regex expression
func split(usingRegex pattern: String) -> [String] {
// Crashes when you pass invalid pattern
let regex = try! NSRegularExpression(pattern: pattern)
let matches = regex.matches(in: self, range: NSRange(0..<utf16.count))
let ranges = [startIndex..<startIndex] + matches.map{Range($0.range, in: self)!} + [endIndex..<endIndex]
return (0...matches.count).map {String(self[ranges[$0].upperBound..<ranges[$0+1].lowerBound])}
}
}

struct Line: Shape {
Expand All @@ -213,14 +221,3 @@ struct Line: Shape {
return path
}
}

// Used for splitting string by regex expression
extension String {
func split(usingRegex pattern: String) -> [String] {
// Crashes when you pass invalid pattern
let regex = try! NSRegularExpression(pattern: pattern)
let matches = regex.matches(in: self, range: NSRange(0..<utf16.count))
let ranges = [startIndex..<startIndex] + matches.map{Range($0.range, in: self)!} + [endIndex..<endIndex]
return (0...matches.count).map {String(self[ranges[$0].upperBound..<ranges[$0+1].lowerBound])}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct DiningVenueView: View {
await diningVM.refreshVenues()
await diningVM.refreshBalance()
await diningVM.refreshMenus(cache: true)
await diningAnalyticsViewModel.refresh(refreshWidgets: true)
}
.navigationBarHidden(false)
.listStyle(.plain)
Expand Down

0 comments on commit 82d089f

Please sign in to comment.