Fix attachment download resumption

pull/365/head
Niels Andriesse 4 years ago
parent 5ed5c02ad4
commit aa68e91a4d

@ -37,17 +37,17 @@ final class DownloadAttachmentModal : Modal {
messageLabel.numberOfLines = 0 messageLabel.numberOfLines = 0
messageLabel.lineBreakMode = .byWordWrapping messageLabel.lineBreakMode = .byWordWrapping
messageLabel.textAlignment = .center messageLabel.textAlignment = .center
// Unblock button // Download button
let unblockButton = UIButton() let downloadButton = UIButton()
unblockButton.set(.height, to: Values.mediumButtonHeight) downloadButton.set(.height, to: Values.mediumButtonHeight)
unblockButton.layer.cornerRadius = Modal.buttonCornerRadius downloadButton.layer.cornerRadius = Modal.buttonCornerRadius
unblockButton.backgroundColor = Colors.buttonBackground downloadButton.backgroundColor = Colors.buttonBackground
unblockButton.titleLabel!.font = .systemFont(ofSize: Values.smallFontSize) downloadButton.titleLabel!.font = .systemFont(ofSize: Values.smallFontSize)
unblockButton.setTitleColor(Colors.text, for: UIControl.State.normal) downloadButton.setTitleColor(Colors.text, for: UIControl.State.normal)
unblockButton.setTitle("Download", for: UIControl.State.normal) downloadButton.setTitle("Download", for: UIControl.State.normal)
unblockButton.addTarget(self, action: #selector(trust), for: UIControl.Event.touchUpInside) downloadButton.addTarget(self, action: #selector(trust), for: UIControl.Event.touchUpInside)
// Button stack view // Button stack view
let buttonStackView = UIStackView(arrangedSubviews: [ cancelButton, unblockButton ]) let buttonStackView = UIStackView(arrangedSubviews: [ cancelButton, downloadButton ])
buttonStackView.axis = .horizontal buttonStackView.axis = .horizontal
buttonStackView.spacing = Values.mediumSpacing buttonStackView.spacing = Values.mediumSpacing
buttonStackView.distribution = .fillEqually buttonStackView.distribution = .fillEqually

@ -88,6 +88,7 @@ extension Storage {
let jobs = getAttachmentDownloadJobs(for: tsMessageID) let jobs = getAttachmentDownloadJobs(for: tsMessageID)
jobs.forEach { job in jobs.forEach { job in
job.delegate = JobQueue.shared job.delegate = JobQueue.shared
job.isDeferred = false
job.execute() job.execute()
} }
} }

@ -36,13 +36,12 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject
public init?(coder: NSCoder) { public init?(coder: NSCoder) {
guard let attachmentID = coder.decodeObject(forKey: "attachmentID") as! String?, guard let attachmentID = coder.decodeObject(forKey: "attachmentID") as! String?,
let tsMessageID = coder.decodeObject(forKey: "tsIncomingMessageID") as! String?, let tsMessageID = coder.decodeObject(forKey: "tsIncomingMessageID") as! String?,
let id = coder.decodeObject(forKey: "id") as! String?, let id = coder.decodeObject(forKey: "id") as! String? else { return nil }
let isDeferred = coder.decodeObject(forKey: "isDeferred") as! Bool? else { return nil }
self.attachmentID = attachmentID self.attachmentID = attachmentID
self.tsMessageID = tsMessageID self.tsMessageID = tsMessageID
self.id = id self.id = id
self.failureCount = coder.decodeObject(forKey: "failureCount") as! UInt? ?? 0 self.failureCount = coder.decodeObject(forKey: "failureCount") as! UInt? ?? 0
self.isDeferred = isDeferred self.isDeferred = coder.decodeBool(forKey: "isDeferred")
} }
public func encode(with coder: NSCoder) { public func encode(with coder: NSCoder) {

Loading…
Cancel
Save