feature: sent-PDF history (10) + image retention (30) with pruning per Ben's 2026-09-02 ruling

This commit is contained in:
2026-09-02 10:27:11 +04:00
parent 8338216f23
commit 15adeec2c1
7 changed files with 966 additions and 11 deletions
+16
View File
@@ -100,6 +100,8 @@ extension AppModel: SendCapable {
/// `NSSharingServiceDelegate.sharingService(_:didShareItems:)` seam.
func handleDidShareItems(fileName: String, pageCount: Int) async {
guard !session.isEmpty else { return }
let sentSessionID = session.id
let sourceURL = lastComposedPDFURL ?? outboxURL.appendingPathComponent(fileName)
do {
_ = try await spool.archiveCurrent(pdfFileName: fileName)
replaceSession(try await spool.currentSession())
@@ -107,6 +109,20 @@ extension AppModel: SendCapable {
setStatus("Sent — \(pageCount) \(pageWord).")
} catch {
setStatus((error as? ShotdeckError)?.errorDescription ?? "Could not archive the session.")
return
}
do {
_ = try await historyStore.recordSentPDF(
sourceURL: sourceURL,
sessionID: sentSessionID,
pageCount: pageCount,
sentAt: Date()
)
try await historyStore.pruneImages()
} catch {
Log.spool.error(
"Could not record sent PDF into history at \(sourceURL.path, privacy: .public): \(error.localizedDescription, privacy: .public)"
)
}
}