Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SwiftLeeds/Network/URLSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public extension URLSession {
let filename = filename ?? request.url.lastPathComponent
let path = fileManager.temporaryDirectory.appendingPathComponent(filename)

guard let data = fileManager.contents(atPath: path.path.appending(".json")) else { throw NetworkError.cacheNotFound }
guard let data = fileManager.contents(atPath: path.appendingPathExtension("json").path) else { throw NetworkError.cacheNotFound }

let decoded = Task.detached(priority: .userInitiated) {
try Task.checkCancellation()
Expand All @@ -39,7 +39,7 @@ public extension URLSession {
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy?,
fileManager: FileManager = .default, filename: String? = nil) async throws -> Response {
let filename = filename ?? request.url.lastPathComponent
let path = fileManager.temporaryDirectory.appendingPathComponent("\(filename).json")
let path = fileManager.temporaryDirectory.appendingPathComponent(filename).appendingPathExtension("json")

let decoded = Task.detached(priority: .userInitiated) {
do {
Expand Down
2 changes: 1 addition & 1 deletion SwiftLeeds/Views/Local/LocalViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LocalViewModel: ObservableObject {

func loadData() async {
do {
let localResults = try await URLSession.awaitConnectivity.decode(Requests.local, dateDecodingStrategy: Requests.defaultDateDecodingStratergy)
let localResults = try await URLSession.shared.decode(Requests.local, dateDecodingStrategy: Requests.defaultDateDecodingStratergy)
await updateLocal(localResults)
} catch {
if let cachedResponse = try? await URLSession.shared.cached(Requests.local, dateDecodingStrategy: Requests.defaultDateDecodingStratergy) {
Expand Down
2 changes: 2 additions & 0 deletions SwiftLeeds/Views/My Conference/MyConferenceViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class MyConferenceViewModel: ObservableObject {
Requests.schedule,
dateDecodingStrategy: Requests.scheduleDateDecodingStrategy
)

await updateSchedule(schedule)

do {
Expand Down Expand Up @@ -73,6 +74,7 @@ class MyConferenceViewModel: ObservableObject {
dateDecodingStrategy: Requests.scheduleDateDecodingStrategy,
filename: "schedule-\(currentEvent.id.uuidString)"
)

await updateSchedule(schedule)
}

Expand Down
2 changes: 1 addition & 1 deletion SwiftLeeds/Views/Sponsors/SponsorsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class SponsorsViewModel: ObservableObject {

func loadSponsors() async throws {
do {
let sponsors = try await URLSession.awaitConnectivity.decode(Requests.sponsors, dateDecodingStrategy: Requests.defaultDateDecodingStratergy)
let sponsors = try await URLSession.shared.decode(Requests.sponsors, dateDecodingStrategy: Requests.defaultDateDecodingStratergy)
await updateSponsors(sponsors)
} catch {
if let cachedResponse = try? await URLSession.shared.cached(Requests.sponsors, dateDecodingStrategy: Requests.defaultDateDecodingStratergy) {
Expand Down