Add in-app diagnostic logging + resilient inbox; bump to 1.2
Build iOS App / Build .ipa and publish source (push) Failing after 5m44s
Build iOS App / Build .ipa and publish source (push) Failing after 5m44s
- LogStore: bounded in-memory + persisted log of API calls and errors, viewable and shareable from Settings → View logs. - GiteaClient: log every request/response status (esp. 404s). - Inbox: a single failing repo no longer wipes the whole inbox — per-repo errors are caught, logged, and the rest still load. - Bump to 1.2 so SideStore offers the update.
This commit is contained in:
1 parent
43f4d76356
commit
b51b2ee5c8
6 files changed
+202
-11
No files matched your search
@@ -70,25 +70,45 @@ final class InboxViewModel: ObservableObject {
|
||||
|
||||
do {
|
||||
let repos = try await client.repos()
|
||||
// Fetch open PRs across all repos concurrently.
|
||||
LogStore.shared.log(.info, "Inbox: \(repos.count) repos")
|
||||
// Fetch open PRs across all repos concurrently. A single repo that
|
||||
// fails (e.g. 404) must NOT wipe the whole inbox — catch per-repo
|
||||
// errors, log them, and keep whatever succeeded.
|
||||
var rows: [PRRow] = []
|
||||
try await withThrowingTaskGroup(of: [PRRow].self) { group in
|
||||
var failures: [String] = []
|
||||
await withTaskGroup(of: Result<[PRRow], Error>.self) { group in
|
||||
for repo in repos {
|
||||
group.addTask {
|
||||
let prs = try await client.pullRequests(owner: repo.owner.login,
|
||||
repo: repo.name)
|
||||
return try await self.enrich(prs, in: repo, client: client)
|
||||
do {
|
||||
let prs = try await client.pullRequests(owner: repo.owner.login,
|
||||
repo: repo.name)
|
||||
return .success(try await self.enrich(prs, in: repo, client: client))
|
||||
} catch {
|
||||
return .failure(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
for try await batch in group {
|
||||
rows.append(contentsOf: batch)
|
||||
for await result in group {
|
||||
switch result {
|
||||
case .success(let batch):
|
||||
rows.append(contentsOf: batch)
|
||||
case .failure(let error):
|
||||
failures.append(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !failures.isEmpty {
|
||||
LogStore.shared.log(.warn, "Inbox: \(failures.count) repo(s) failed: \(failures.joined(separator: "; "))")
|
||||
}
|
||||
// Sort: most recently updated first.
|
||||
rows.sort { ($0.pr.updatedAt ?? .distantPast) > ($1.pr.updatedAt ?? .distantPast) }
|
||||
allRows = rows
|
||||
recomputeDisplayed()
|
||||
if rows.isEmpty && !failures.isEmpty {
|
||||
errorMessage = "Couldn't load any PRs (\(failures.count) repo(s) failed). Check the Logs screen."
|
||||
}
|
||||
} catch {
|
||||
LogStore.shared.log(.error, "Inbox load failed: \(error.localizedDescription)")
|
||||
errorMessage = error.localizedDescription
|
||||
allRows = []
|
||||
recomputeDisplayed()
|
||||
|
||||
Reference in new issue
Block a user