05/04 Update the app functionalities

This commit is contained in:
Nguyen Ngo
2026-05-04 17:36:55 -04:00
parent 09715e9c11
commit 9d6b5e5bcb
7 changed files with 980 additions and 131 deletions
+12 -6
View File
@@ -37,10 +37,12 @@ private struct _Envelope<T: Decodable & Sendable>: Decodable, Sendable {
private enum CodingKeys: String, CodingKey { case ok, data, error }
}
// Refresh-only envelope uses a non-Sendable-constrained local struct
// decoded manually to avoid pulling RefreshResponseData into the Sendable chain.
private struct _RefreshEnvelope: Decodable {
struct Tokens: Decodable {
// Free function removed see refreshAccessToken() which decodes using a
// local JSONDecoder to avoid Swift 6 actor-isolation errors.
// Refresh-only envelope Sendable so it can cross actor boundaries in Swift 6.
private struct _RefreshEnvelope: Decodable, Sendable {
struct Tokens: Decodable, Sendable {
let accessToken: String
let refreshToken: String
}
@@ -170,7 +172,7 @@ actor APIClient {
func submitIssue(_ issue: LocalIssue) async throws -> Int {
var body: [String: Any] = [
"area_id": issue.areaServerId,
"facility_id": issue.facilityServerId,
"severity": issue.severity,
"description": issue.issueDescription,
"mobile_local_id": issue.localId,
@@ -199,7 +201,11 @@ actor APIClient {
let http = response as? HTTPURLResponse, http.statusCode == 200
else { return false }
guard let env = try? decoder.decode(_RefreshEnvelope.self, from: data),
// Use a local decoder avoids referencing the actor-isolated self.decoder
// which would trigger a Swift 6 main-actor isolation error.
let localDecoder = JSONDecoder()
localDecoder.keyDecodingStrategy = .convertFromSnakeCase
guard let env = try? localDecoder.decode(_RefreshEnvelope.self, from: data),
env.ok,
let tokens = env.data
else { return false }