Only send the last_sync param if it's set

This commit is contained in:
Shadowfacts 2023-01-14 12:16:46 -05:00
parent 002c931d26
commit 3941133fcf
1 changed files with 5 additions and 3 deletions

View File

@ -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)
}