05/11 Update issue image upload

This commit is contained in:
Nguyen Ngo
2026-05-11 17:31:21 -04:00
parent 6367dac1e6
commit 9fd3f5b829
6 changed files with 223 additions and 67 deletions
+18 -4
View File
@@ -16,8 +16,22 @@ final class LocalIssue {
var severity: String // "low" | "medium" | "high" | "critical"
var issueDescription: String
var issueStatus: String = "open" // server status: "open" | "in_progress" | "resolved" | "pending_verification"
var photoLocalPath: String? // local file path before upload
var photoServerPath: String? // server path after upload
/// JSON-encoded array of absolute local file paths, e.g. ["/var/.../photo1.jpg", ...]
var photoLocalPathsJSON: String = "[]"
/// JSON-encoded array of server paths after upload, e.g. ["uploads/issue_photos/abc.jpg", ...]
var photoServerPathsJSON: String = "[]"
/// Decoded local photo paths (up to 5)
var photoLocalPaths: [String] {
get { (try? JSONDecoder().decode([String].self, from: Data(photoLocalPathsJSON.utf8))) ?? [] }
set { photoLocalPathsJSON = (try? String(data: JSONEncoder().encode(newValue), encoding: .utf8)) ?? "[]" }
}
/// Decoded server photo paths
var photoServerPaths: [String] {
get { (try? JSONDecoder().decode([String].self, from: Data(photoServerPathsJSON.utf8))) ?? [] }
set { photoServerPathsJSON = (try? String(data: JSONEncoder().encode(newValue), encoding: .utf8)) ?? "[]" }
}
var createdAt: Date
var syncStatus: String // "pending" | "synced" | "failed"
@@ -39,8 +53,8 @@ final class LocalIssue {
self.severity = severity
self.issueDescription = description
self.issueStatus = "open"
self.photoLocalPath = nil
self.photoServerPath = nil
self.photoLocalPathsJSON = "[]"
self.photoServerPathsJSON = "[]"
self.createdAt = Date()
self.syncStatus = "pending"
self.syncRetryCount = 0