From 3941133fcf28f0ba81658a33343051e2d181fc0f Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 14 Jan 2023 12:16:46 -0500 Subject: [PATCH] Only send the last_sync param if it's set --- Fervor/Sources/Fervor/FervorClient.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Fervor/Sources/Fervor/FervorClient.swift b/Fervor/Sources/Fervor/FervorClient.swift index 4bd4005..2636767 100644 --- a/Fervor/Sources/Fervor/FervorClient.swift +++ b/Fervor/Sources/Fervor/FervorClient.swift @@ -103,9 +103,11 @@ public actor FervorClient: Sendable { } public func syncItems(lastSync: Date?) async throws -> ItemsSyncUpdate { - let request = URLRequest(url: buildURL(path: "/api/v1/items/sync", queryItems: [ - URLQueryItem(name: "last_sync", value: lastSync?.formatted(.iso8601)) - ])) + var query: [URLQueryItem] = [] + if let lastSync { + query.append(URLQueryItem(name: "last_sync", value: lastSync.formatted(.iso8601))) + } + let request = URLRequest(url: buildURL(path: "/api/v1/items/sync", queryItems: query)) return try await performRequest(request) }