WIP
This commit is contained in:
parent
70fb7eb185
commit
19c29b2bf9
|
@ -3225,7 +3225,6 @@ typedef enum : NSUInteger {
|
|||
}];
|
||||
return;
|
||||
}
|
||||
|
||||
for (SignalAttachment *attachment in attachments) {
|
||||
if ([attachment hasError]) {
|
||||
OWSLogWarn(@"Invalid attachment: %@.", attachment ? [attachment errorName] : @"Missing data");
|
||||
|
@ -3233,21 +3232,15 @@ typedef enum : NSUInteger {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
__block TSOutgoingMessage *message;
|
||||
|
||||
// TODO TODO TODO
|
||||
|
||||
// [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
|
||||
// message = [ThreadUtil enqueueMessageWithText:messageText
|
||||
// mediaAttachments:attachments
|
||||
// inThread:self.thread
|
||||
// quotedReplyModel:self.inputToolbar.quotedReply
|
||||
// linkPreviewDraft:nil
|
||||
// transaction:transaction];
|
||||
// }];
|
||||
|
||||
[self messageWasSent:message];
|
||||
SNVisibleMessage *message = [SNVisibleMessage new];
|
||||
message.sentTimestamp = [NSDate millisecondTimestamp];
|
||||
TSThread *thread = self.thread;
|
||||
TSOutgoingMessage *tsMessage = [TSOutgoingMessage from:message associatedWith:thread];
|
||||
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[tsMessage saveWithTransaction:transaction];
|
||||
[SNMessageSender send:message withAttachments:attachments inThread:thread usingTransaction:transaction];
|
||||
}];
|
||||
[self messageWasSent:tsMessage];
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3817,7 +3810,7 @@ typedef enum : NSUInteger {
|
|||
[self.conversationViewModel appendUnsavedOutgoingTextMessage:tsMessage];
|
||||
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||
[tsMessage saveWithTransaction:transaction];
|
||||
[SNMessageSender send:message inThread:thread usingTransaction:transaction];
|
||||
[SNMessageSender send:message withAttachments:[NSArray<SignalAttachment *> new] inThread:thread usingTransaction:transaction];
|
||||
[thread setDraft:@"" transaction:transaction];
|
||||
}];
|
||||
[self messageWasSent:tsMessage];
|
||||
|
|
|
@ -6,8 +6,11 @@ public final class JobQueue : NSObject, JobDelegate {
|
|||
@objc public static let shared = JobQueue()
|
||||
|
||||
@objc public func add(_ job: Job, using transaction: Any) {
|
||||
let transaction = transaction as! YapDatabaseReadWriteTransaction
|
||||
addWithoutExecuting(job, using: transaction)
|
||||
job.execute()
|
||||
transaction.addCompletionQueue(Threading.workQueue) {
|
||||
job.execute()
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func addWithoutExecuting(_ job: Job, using transaction: Any) {
|
||||
|
|
|
@ -2,8 +2,17 @@ import PromiseKit
|
|||
|
||||
public extension MessageSender {
|
||||
|
||||
@objc(send:inThread:usingTransaction:)
|
||||
static func send(_ message: Message, in thread: TSThread, using transaction: YapDatabaseReadWriteTransaction) {
|
||||
@objc(send:withAttachments:inThread:usingTransaction:)
|
||||
static func send(_ message: Message, with attachments: [SignalAttachment] = [], in thread: TSThread, using transaction: YapDatabaseReadWriteTransaction) {
|
||||
if let message = message as? VisibleMessage {
|
||||
let streams = attachments.map {
|
||||
return TSAttachmentStream(contentType: $0.mimeType, byteCount: UInt32($0.dataLength), sourceFilename: $0.sourceFilename,
|
||||
caption: $0.captionText, albumMessageId: nil
|
||||
)
|
||||
}
|
||||
streams.forEach { $0.save(with: transaction) }
|
||||
message.attachmentIDs = streams.map { $0.uniqueId! }
|
||||
}
|
||||
message.threadID = thread.uniqueId!
|
||||
let destination = Message.Destination.from(thread)
|
||||
let job = MessageSendJob(message: message, destination: destination)
|
||||
|
|
Loading…
Reference in New Issue