Skip to content

Commit

Permalink
Replace static DestinationManager attributes with direct settings ref…
Browse files Browse the repository at this point in the history
…erences
  • Loading branch information
steinbro committed Sep 5, 2024
1 parent 1033ea5 commit 4520c53
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class BeaconCalloutGenerator: AutomaticGenerator, ManualGenerator {
}

// Don't do a location update for the destination if we have already entered the immediate vicinity
guard destination.distanceToClosestLocation(from: location) > DestinationManager.EnterImmediateVicinityDistance else {
guard destination.distanceToClosestLocation(from: location) > SettingsContext.shared.enterImmediateVicinityDistance else {
return nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct DestinationCallout: POICalloutProtocol {
return Sounds(sounds)

case .beaconGeofence:
let formattedDistance = LanguageFormatter.formattedDistance(from: DestinationManager.EnterImmediateVicinityDistance)
let formattedDistance = LanguageFormatter.formattedDistance(from: SettingsContext.shared.enterImmediateVicinityDistance)

// Inform the user why the audio beacon has stopped
if causedAudioDisabled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct PreviewGenerator<DecisionPoint: RootedPreviewGraph>: ManualGenerator {
var callouts: [CalloutProtocol] = []

if event.arrived {
let formattedDistance = LanguageFormatter.formattedDistance(from: DestinationManager.EnterImmediateVicinityDistance)
let formattedDistance = LanguageFormatter.formattedDistance(from: SettingsContext.shared.enterImmediateVicinityDistance)

callouts.append(GenericCallout(.preview, description: "arrived at beacon (in preview)") { (_, _, _) -> [Sound] in
let earcon = GlyphSound(.beaconFound)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ enum DestinationManagerError: Error {

class DestinationManager: DestinationManagerProtocol {

static let LeaveImmediateVicinityDistance: CLLocationDistance = SettingsContext.shared.leaveImmediateVicinityDistance
static let EnterImmediateVicinityDistance: CLLocationDistance = SettingsContext.shared.enterImmediateVicinityDistance

// MARK: Notification Keys

struct Keys {
Expand Down Expand Up @@ -614,10 +611,10 @@ class DestinationManager: DestinationManagerProtocol {

let distance = origin.distanceToClosestLocation(from: location)

if isWithinGeofence && distance >= DestinationManager.LeaveImmediateVicinityDistance {
if isWithinGeofence && distance >= SettingsContext.shared.leaveImmediateVicinityDistance {
// Left immediate vicinity
return false
} else if !isWithinGeofence && distance <= DestinationManager.EnterImmediateVicinityDistance {
} else if !isWithinGeofence && distance <= SettingsContext.shared.enterImmediateVicinityDistance {
// Entered immediate vicinity
return true
}
Expand Down

0 comments on commit 4520c53

Please sign in to comment.