Skip to content

Commit

Permalink
Apply minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
manu-r12 committed Dec 10, 2024
1 parent bce9527 commit 9e4e4c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
11 changes: 1 addition & 10 deletions OBAKitCore/Orchestration/CoreApplication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ open class CoreApplication: NSObject,
}

/// This function reloads the REST API and Obaco Services.
private func refreshServices() {
public func refreshServices() {
refreshRESTAPIService()
refreshObacoService()
apiServicesRefreshed()
Expand Down Expand Up @@ -129,15 +129,6 @@ open class CoreApplication: NSObject,
self.apiService = RESTAPIService(APIServiceConfiguration(baseURL: region.OBABaseURL, apiKey: config.apiKey, uuid: userUUID, appVersion: config.appVersion, regionIdentifier: region.regionIdentifier))
}

public func getNewRefreshedRESTAPIService() -> RESTAPIService? {
guard let region = regionsService.currentRegion else {
return nil
}
let apiService = RESTAPIService(APIServiceConfiguration(baseURL: region.OBABaseURL, apiKey: config.apiKey, uuid: userUUID, appVersion: config.appVersion, regionIdentifier: region.regionIdentifier))

return apiService
}

// MARK: - Obaco

public private(set) var obacoService: ObacoAPIService? {
Expand Down
6 changes: 4 additions & 2 deletions OBAWidget/Provider/WidgetDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ class WidgetDataProvider: NSObject, ObservableObject {

/// Loads arrivals and departures for all favorited bookmarks for the widget.
func loadData() async {
arrDepDic = [:]

guard let apiService = app.getNewRefreshedRESTAPIService() else {
arrDepDic = [:]
app.refreshServices()

guard let apiService = app.apiService else {
Logger.error("Failed to get REST API Service.")
return
}
Expand Down

0 comments on commit 9e4e4c3

Please sign in to comment.