From e92153a7508243c24423ecee1a5b8ee7223f1037 Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Fri, 23 Oct 2026 19:28:58 -0500 Subject: [PATCH] Put the report name in the subject when sharing the diagnostic report Sharing passed only the file URL, so Mail left the subject blank. The old issue report shared through an activity item source that supplied the report name as the subject; do the same here. (cherry picked from commit 36e436d109d72c66ec7392f64a697e9fa6967cb6) --- .../IssueReport/DiagnosticReportView.swift | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/LoopSupportKitUI/IssueReport/DiagnosticReportView.swift b/LoopSupportKitUI/IssueReport/DiagnosticReportView.swift index 705cf97..f88395d 100644 --- a/LoopSupportKitUI/IssueReport/DiagnosticReportView.swift +++ b/LoopSupportKitUI/IssueReport/DiagnosticReportView.swift @@ -16,6 +16,7 @@ struct DiagnosticReportView: View { private struct ReportFile: Identifiable { let url: URL + let name: String var id: URL { url } } @@ -40,7 +41,7 @@ struct DiagnosticReportView: View { } } .sheet(item: $reportFile, onDismiss: removeReportFile) { file in - ActivityView(activityItems: [file.url]) + ActivityView(activityItems: [ReportItem(url: file.url, subject: file.name)]) } .task { if report == nil { @@ -56,7 +57,7 @@ struct DiagnosticReportView: View { let name = "Loop Report \(ISO8601DateFormatter.string(from: Date(), timeZone: .current, formatOptions: [.withSpaceBetweenDateAndTime, .withInternetDateTime])).md" let url = FileManager.default.temporaryDirectory.appendingPathComponent(name.replacingOccurrences(of: ":", with: "-")) if (try? report.write(to: url, atomically: true, encoding: .utf8)) != nil { - reportFile = ReportFile(url: url) + reportFile = ReportFile(url: url, name: name) } } @@ -98,3 +99,26 @@ private struct ActivityView: UIViewControllerRepresentable { func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {} } + +// Supplies the report name as the subject, e.g. for Mail +private final class ReportItem: NSObject, UIActivityItemSource { + let url: URL + let subject: String + + init(url: URL, subject: String) { + self.url = url + self.subject = subject + } + + func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any { + url + } + + func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? { + url + } + + func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivity.ActivityType?) -> String { + subject + } +}