iOS transfers: 'Uploading...' then 'Uploaded' notification, and count share uploads
The Share Extension's session had no delegate, so a fast upload finished unseen and the invalidated session was discarded before the app could hear of it - no summary notification. Results are now handled by a shared delegate in whichever process is alive, started/finished notifications replace each other in place, and the app refreshes the folder the extension uploaded to. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
afc9b90963
commit
0c063c1fb4
@@ -47,6 +47,27 @@ enum TransferBatchStore {
|
||||
if let data = try? JSONEncoder().encode(batch) { defaults.set(data, forKey: key(id)) }
|
||||
}
|
||||
|
||||
private static let finishedFoldersKey = "transfer.finishedUploadFolders"
|
||||
|
||||
/// The Share Extension finished an upload into [folder] while the app
|
||||
/// wasn't running; the app reads this on its next activation so its file
|
||||
/// list can refresh.
|
||||
static func noteFinishedUpload(folder: String) {
|
||||
lock.lock()
|
||||
defer { lock.unlock() }
|
||||
var folders = defaults.stringArray(forKey: finishedFoldersKey) ?? []
|
||||
if !folders.contains(folder) { folders.append(folder) }
|
||||
defaults.set(folders, forKey: finishedFoldersKey)
|
||||
}
|
||||
|
||||
static func consumeFinishedUploadFolders() -> [String] {
|
||||
lock.lock()
|
||||
defer { lock.unlock() }
|
||||
let folders = defaults.stringArray(forKey: finishedFoldersKey) ?? []
|
||||
defaults.removeObject(forKey: finishedFoldersKey)
|
||||
return folders
|
||||
}
|
||||
|
||||
/// Counts one file's outcome. Returns the batch when that was its last
|
||||
/// file (and forgets it), nil while others are still running.
|
||||
static func record(_ info: TransferTaskInfo, success: Bool) -> TransferBatch? {
|
||||
|
||||
Reference in New Issue
Block a user