05/15 Update: show issue's images, push notifications

This commit is contained in:
Nguyen Ngo
2026-05-15 15:41:13 -04:00
parent 9fd3f5b829
commit 7320e88dec
7 changed files with 398 additions and 14 deletions
+30
View File
@@ -219,6 +219,36 @@ actor APIClient {
return result.status
}
// Notification polling (Phase C)
/// Fetch notifications, optionally scoped to those created after `since`.
func fetchNotifications(since: Date? = nil) async throws -> [APINotification] {
var ep = "/api/v1/notifications"
if let since {
let fmt = DateFormatter()
fmt.dateFormat = "yyyy-MM-dd'T'HH:mm:ss"
ep += "?since=\(fmt.string(from: since))"
}
let result: APINotificationsResponseData = try await request(ep)
return result.notifications
}
/// Mark the given notification IDs as read on the server.
func markNotificationsRead(ids: [Int]) async throws {
guard !ids.isEmpty else { return }
let _: APIMarkReadResponseData = try await request(
"/api/v1/notifications/mark-read",
method: "PATCH",
body: ["ids": ids]
)
}
/// Fetch issues assigned to the current user from the server.
func fetchAssignedIssues() async throws -> [APIAssignedIssue] {
let result: APIAssignedIssuesResponseData = try await request("/api/v1/issues")
return result.issues
}
// Token Refresh
private func refreshAccessToken() async -> Bool {