Skip to content

Commit bee6fa7

Browse files
authored
fix: concurrency warnings pre swift 6 support (#428)
1 parent 6588f13 commit bee6fa7

File tree

3 files changed

+6
-32
lines changed

3 files changed

+6
-32
lines changed

Sources/Auth/Defaults.swift

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,13 @@ import Foundation
99
import Helpers
1010

1111
extension AuthClient.Configuration {
12-
private static let dateFormatterWithFractionalSeconds = { () -> ISO8601DateFormatter in
13-
let formatter = ISO8601DateFormatter()
14-
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
15-
return formatter
16-
}()
17-
18-
private static let dateFormatter = { () -> ISO8601DateFormatter in
19-
let formatter = ISO8601DateFormatter()
20-
formatter.formatOptions = [.withInternetDateTime]
21-
return formatter
22-
}()
23-
2412
/// The default JSONEncoder instance used by the ``AuthClient``.
2513
public static let jsonEncoder: JSONEncoder = {
2614
let encoder = JSONEncoder()
2715
encoder.keyEncodingStrategy = .convertToSnakeCase
2816
encoder.dateEncodingStrategy = .custom { date, encoder in
2917
var container = encoder.singleValueContainer()
30-
let string = dateFormatterWithFractionalSeconds.string(from: date)
18+
let string = DateFormatter.iso8601.string(from: date)
3119
try container.encode(string)
3220
}
3321
return encoder
@@ -41,7 +29,7 @@ extension AuthClient.Configuration {
4129
let container = try decoder.singleValueContainer()
4230
let string = try container.decode(String.self)
4331

44-
let supportedFormatters = [dateFormatterWithFractionalSeconds, dateFormatter]
32+
let supportedFormatters: [DateFormatter] = [.iso8601, .iso8601_noMilliseconds]
4533

4634
for formatter in supportedFormatters {
4735
if let date = formatter.date(from: string) {

Sources/Helpers/SupabaseLogger.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public struct SupabaseLogMessage: Codable, CustomStringConvertible, Sendable {
5555
}
5656

5757
public var description: String {
58-
let date = iso8601Formatter.string(from: Date(timeIntervalSince1970: timestamp))
58+
let date = DateFormatter.iso8601_noMilliseconds.string(from: Date(timeIntervalSince1970: timestamp))
5959
let file = fileID.split(separator: ".", maxSplits: 1).first.map(String.init) ?? fileID
6060
var description = "\(date) [\(level)] [\(system)] [\(file).\(function):\(line)] \(message)"
6161
if !additionalContext.isEmpty {
@@ -65,12 +65,6 @@ public struct SupabaseLogMessage: Codable, CustomStringConvertible, Sendable {
6565
}
6666
}
6767

68-
private let iso8601Formatter: ISO8601DateFormatter = {
69-
let formatter = ISO8601DateFormatter()
70-
formatter.formatOptions = [.withInternetDateTime]
71-
return formatter
72-
}()
73-
7468
public protocol SupabaseLogger: Sendable {
7569
func log(message: SupabaseLogMessage)
7670
}

Sources/PostgREST/Defaults.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,9 @@ import Helpers
1111
let version = Helpers.version
1212

1313
extension PostgrestClient.Configuration {
14-
private static let supportedDateFormatters: [ISO8601DateFormatter] = [
15-
{ () -> ISO8601DateFormatter in
16-
let formatter = ISO8601DateFormatter()
17-
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
18-
return formatter
19-
}(),
20-
{ () -> ISO8601DateFormatter in
21-
let formatter = ISO8601DateFormatter()
22-
formatter.formatOptions = [.withInternetDateTime]
23-
return formatter
24-
}(),
14+
private static let supportedDateFormatters: [DateFormatter] = [
15+
.iso8601,
16+
.iso8601_noMilliseconds,
2517
]
2618

2719
/// The default `JSONDecoder` instance for ``PostgrestClient`` responses.

0 commit comments

Comments
 (0)