Fill in some gaps

This commit is contained in:
nielsandriesse 2020-11-24 09:49:31 +11:00
parent aec182f36c
commit 4317b17e7e
5 changed files with 25 additions and 3 deletions

View File

@ -217,6 +217,10 @@ static NSTimeInterval launchStartedAt;
[SNConfiguration performMainSetup];
if (CurrentAppContext().isMainApp) {
[SNJobQueue resumePendingJobs];
}
[LKAppearanceUtilities switchToSessionAppearance];
if (CurrentAppContext().isRunningTests) {

View File

@ -2,7 +2,7 @@ import SessionUtilitiesKit
public final class AttachmentUploadJob : NSObject, Job, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
public var delegate: JobDelegate?
private let attachmentID: String
public let attachmentID: String
private let threadID: String
public var id: String?
public var failureCount: UInt = 0

View File

@ -77,6 +77,7 @@ public final class MessageSendJob : NSObject, Job, NSCoding { // NSObject/NSCodi
}
if !attachmentsToUpload.isEmpty { delegate?.postpone(self); return } // Wait for all attachments to upload before continuing
}
// FIXME: This doesn't yet handle the attachment side of link previews, quotes, etc.
storage.withAsync({ transaction in // Intentionally capture self
Threading.workQueue.async {
MessageSender.send(self.message, to: self.destination, using: transaction).done(on: Threading.workQueue) {

View File

@ -55,7 +55,14 @@ public final class VisibleMessage : Message {
dataMessage = SNProtoDataMessage.builder()
}
if let text = text { dataMessage.setBody(text) }
// TODO: Attachments
let attachments = attachmentIDs.compactMap { TSAttachmentStream.fetch(uniqueId: $0) }
if !attachments.allSatisfy({ $0.isUploaded }) {
#if DEBUG
preconditionFailure("Sending a message before all associated attachments have been uploaded.")
#endif
}
let attachmentProtos = attachments.compactMap { TSAttachmentStream.buildProto(forAttachmentId: $0.uniqueId!) }
dataMessage.setAttachments(attachmentProtos)
if let quote = quote, let quoteProto = quote.toProto() { dataMessage.setQuote(quoteProto) }
if let linkPreview = linkPreview, let linkPreviewProto = linkPreview.toProto() { dataMessage.setPreview([ linkPreviewProto ]) }
// TODO: Contact

View File

@ -25,6 +25,16 @@ extension Storage {
}
public func getAttachmentUploadJob(for attachmentID: String) -> AttachmentUploadJob? {
return nil // TODO: Implement
var result: [AttachmentUploadJob] = []
Storage.read { transaction in
transaction.enumerateRows(inCollection: AttachmentUploadJob.collection) { _, object, _, _ in
guard let job = object as? AttachmentUploadJob, job.attachmentID == attachmentID else { return }
result.append(job)
}
}
#if DEBUG
assert(result.isEmpty || result.count == 1)
#endif
return result.first
}
}