diff --git a/Forji/Forji/Views/IssueEditView.swift b/Forji/Forji/Views/IssueEditView.swift index 6840f73..68b4a19 100644 --- a/Forji/Forji/Views/IssueEditView.swift +++ b/Forji/Forji/Views/IssueEditView.swift @@ -127,6 +127,14 @@ struct IssueEditView: View { onSaved(updatedIssue) dismiss() } catch { + // The calls above run in sequence with no transaction, so an earlier + // one may already be committed on the server. Re-fetch the issue and + // push the authoritative state to the detail view so it does not show + // stale data, then surface the error and keep the sheet open to retry. + if let refreshed = try? await issueService.fetchIssue(owner: owner, repo: repo, index: issue.number) { + NotificationCenter.default.post(name: .issuesDidChange, object: nil) + onSaved(refreshed) + } errorMessage = error.localizedDescription showError = true } diff --git a/Forji/Forji/Views/PullRequestEditView.swift b/Forji/Forji/Views/PullRequestEditView.swift index fc82fb1..b71e3f1 100644 --- a/Forji/Forji/Views/PullRequestEditView.swift +++ b/Forji/Forji/Views/PullRequestEditView.swift @@ -173,6 +173,16 @@ struct PullRequestEditView: View { onSaved(updatedPR) dismiss() } catch { + // The calls above run in sequence with no transaction, so an earlier + // one may already be committed on the server. Re-fetch the PR and push + // the authoritative state to the detail view so it does not show stale + // data, then surface the error and keep the sheet open to retry. + if let refreshed = try? await prService.fetchPullRequest( + owner: owner, repo: repo, index: pullRequest.number, + ) { + NotificationCenter.default.post(name: .pullRequestsDidChange, object: nil) + onSaved(refreshed) + } errorMessage = error.localizedDescription showError = true }