Debug
This commit is contained in:
parent
58b312f341
commit
921e2bced6
|
@ -132,8 +132,7 @@ final class ConversationCell : UITableViewCell {
|
||||||
// MARK: Updating
|
// MARK: Updating
|
||||||
private func update() {
|
private func update() {
|
||||||
AssertIsOnMainThread()
|
AssertIsOnMainThread()
|
||||||
let thread = threadViewModel.threadRecord
|
guard let thread = threadViewModel?.threadRecord, let threadID = thread.uniqueId else { return }
|
||||||
guard let threadID = thread.uniqueId else { return }
|
|
||||||
MentionsManager.populateUserPublicKeyCacheIfNeeded(for: threadID) // FIXME: This is a terrible place to do this
|
MentionsManager.populateUserPublicKeyCacheIfNeeded(for: threadID) // FIXME: This is a terrible place to do this
|
||||||
let isBlocked: Bool
|
let isBlocked: Bool
|
||||||
if let thread = thread as? TSContactThread {
|
if let thread = thread as? TSContactThread {
|
||||||
|
|
|
@ -3797,7 +3797,6 @@ typedef enum : NSUInteger {
|
||||||
- (void)tryToSendTextMessage:(NSString *)text updateKeyboardState:(BOOL)updateKeyboardState
|
- (void)tryToSendTextMessage:(NSString *)text updateKeyboardState:(BOOL)updateKeyboardState
|
||||||
{
|
{
|
||||||
OWSAssertIsOnMainThread();
|
OWSAssertIsOnMainThread();
|
||||||
|
|
||||||
__weak ConversationViewController *weakSelf = self;
|
__weak ConversationViewController *weakSelf = self;
|
||||||
if ([self isBlockedConversation]) {
|
if ([self isBlockedConversation]) {
|
||||||
[self showUnblockConversationUI:^(BOOL isBlocked) {
|
[self showUnblockConversationUI:^(BOOL isBlocked) {
|
||||||
|
@ -3807,38 +3806,26 @@ typedef enum : NSUInteger {
|
||||||
}];
|
}];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
text = [text ows_stripped];
|
text = [text ows_stripped];
|
||||||
|
|
||||||
if (text.length < 1) { return; }
|
if (text.length < 1) { return; }
|
||||||
|
|
||||||
SNVisibleMessage *message = [SNVisibleMessage new];
|
SNVisibleMessage *message = [SNVisibleMessage new];
|
||||||
[message setSentTimestamp:[NSDate millisecondTimestamp]];
|
message.sentTimestamp = [NSDate millisecondTimestamp];
|
||||||
message.text = text;
|
message.text = text;
|
||||||
message.quote = [SNQuote from:self.inputToolbar.quotedReply];
|
message.quote = [SNQuote from:self.inputToolbar.quotedReply];
|
||||||
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
TSThread *thread = self.thread;
|
||||||
[SNMessageSender send:message inThread:self.thread usingTransaction:transaction];
|
TSOutgoingMessage *tsMessage = [TSOutgoingMessage from:message associatedWith:thread];
|
||||||
}];
|
|
||||||
|
|
||||||
TSOutgoingMessage *tsMessage = [TSOutgoingMessage from:message associatedWith:self.thread];
|
|
||||||
|
|
||||||
[tsMessage save];
|
|
||||||
|
|
||||||
[self.conversationViewModel appendUnsavedOutgoingTextMessage:tsMessage];
|
[self.conversationViewModel appendUnsavedOutgoingTextMessage:tsMessage];
|
||||||
|
|
||||||
[self messageWasSent:tsMessage];
|
|
||||||
|
|
||||||
[self.inputToolbar clearTextMessageAnimated:YES];
|
|
||||||
|
|
||||||
[self resetMentions];
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
[self.inputToolbar toggleDefaultKeyboard];
|
|
||||||
});
|
|
||||||
|
|
||||||
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||||
[self.thread setDraft:@"" transaction:transaction];
|
[tsMessage saveWithTransaction:transaction];
|
||||||
|
[SNMessageSender send:message inThread:thread usingTransaction:transaction];
|
||||||
|
[thread setDraft:@"" transaction:transaction];
|
||||||
}];
|
}];
|
||||||
|
[self messageWasSent:tsMessage];
|
||||||
|
[self.inputToolbar clearTextMessageAnimated:YES];
|
||||||
|
[self resetMentions];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[[weakSelf inputToolbar] toggleDefaultKeyboard];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)voiceMemoGestureDidStart
|
- (void)voiceMemoGestureDidStart
|
||||||
|
@ -4562,7 +4549,10 @@ typedef enum : NSUInteger {
|
||||||
- (void)handleMessageSendingFailedNotification:(NSNotification *)notification
|
- (void)handleMessageSendingFailedNotification:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
NSNumber *timestamp = (NSNumber *)notification.object;
|
NSNumber *timestamp = (NSNumber *)notification.object;
|
||||||
[self hideProgressIndicatorViewForMessageWithTimestamp:timestamp];
|
self.progressIndicatorView.progressTintColor = LKColors.destructive;
|
||||||
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^(void) {
|
||||||
|
[self hideProgressIndicatorViewForMessageWithTimestamp:timestamp];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setProgressIfNeededTo:(float)progress forMessageWithTimestamp:(NSNumber *)timestamp
|
- (void)setProgressIfNeededTo:(float)progress forMessageWithTimestamp:(NSNumber *)timestamp
|
||||||
|
@ -4600,6 +4590,7 @@ typedef enum : NSUInteger {
|
||||||
self.progressIndicatorView.alpha = 0;
|
self.progressIndicatorView.alpha = 0;
|
||||||
} completion:^(BOOL finished) {
|
} completion:^(BOOL finished) {
|
||||||
[self.progressIndicatorView setProgress:0.0f];
|
[self.progressIndicatorView setProgress:0.0f];
|
||||||
|
self.progressIndicatorView.progressTintColor = LKColors.accent;
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1068,17 +1068,6 @@ static const int kYapDatabaseRangeMaxLength = 25000;
|
||||||
OWSAssertDebug(!viewItemCache[interaction.uniqueId]);
|
OWSAssertDebug(!viewItemCache[interaction.uniqueId]);
|
||||||
viewItemCache[interaction.uniqueId] = viewItem;
|
viewItemCache[interaction.uniqueId] = viewItem;
|
||||||
[viewItems addObject:viewItem];
|
[viewItems addObject:viewItem];
|
||||||
TSMessage *message = (TSMessage *)viewItem.interaction;
|
|
||||||
if (message.hasUnfetchedAttachmentsFromPN) {
|
|
||||||
[SSKEnvironment.shared.attachmentDownloads downloadAttachmentsForMessage:message
|
|
||||||
transaction:transaction
|
|
||||||
success:^(NSArray<TSAttachmentStream *> *attachmentStreams) {
|
|
||||||
OWSLogInfo(@"Successfully redownloaded attachment in thread: %@", message.thread);
|
|
||||||
}
|
|
||||||
failure:^(NSError *error) {
|
|
||||||
OWSLogWarn(@"Failed to redownload message with error: %@", error);
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
|
|
||||||
return viewItem;
|
return viewItem;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@ import SessionUtilitiesKit
|
||||||
public final class AttachmentUploadJob : NSObject, Job, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
|
public final class AttachmentUploadJob : NSObject, Job, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
|
||||||
public var delegate: JobDelegate?
|
public var delegate: JobDelegate?
|
||||||
public let attachmentID: String
|
public let attachmentID: String
|
||||||
private let threadID: String
|
public let threadID: String
|
||||||
public var id: String?
|
public var id: String?
|
||||||
public var failureCount: UInt = 0
|
public var failureCount: UInt = 0
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import SessionUtilitiesKit
|
||||||
@objc(SNMessageSendJob)
|
@objc(SNMessageSendJob)
|
||||||
public final class MessageSendJob : NSObject, Job, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
|
public final class MessageSendJob : NSObject, Job, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
|
||||||
public var delegate: JobDelegate?
|
public var delegate: JobDelegate?
|
||||||
private let message: Message
|
public let message: Message
|
||||||
private let destination: Message.Destination
|
private let destination: Message.Destination
|
||||||
public var id: String?
|
public var id: String?
|
||||||
public var failureCount: UInt = 0
|
public var failureCount: UInt = 0
|
||||||
|
|
|
@ -149,9 +149,9 @@ public final class MessageSender : NSObject {
|
||||||
JobQueue.shared.add(notifyPNServerJob, using: transaction)
|
JobQueue.shared.add(notifyPNServerJob, using: transaction)
|
||||||
}, completion: { })
|
}, completion: { })
|
||||||
}
|
}
|
||||||
let _ = promise.catch(on: DispatchQueue.main) { _ in
|
let _ = promise.catch(on: DispatchQueue.main) { error in
|
||||||
storage.withAsync({ transaction in
|
storage.withAsync({ transaction in
|
||||||
Configuration.shared.messageSenderDelegate.handleFailedMessageSend(message, using: transaction)
|
Configuration.shared.messageSenderDelegate.handleFailedMessageSend(message, with: error, using: transaction)
|
||||||
}, completion: { })
|
}, completion: { })
|
||||||
if case .contact(_) = destination {
|
if case .contact(_) = destination {
|
||||||
NotificationCenter.default.post(name: .messageSendingFailed, object: NSNumber(value: message.sentTimestamp!))
|
NotificationCenter.default.post(name: .messageSendingFailed, object: NSNumber(value: message.sentTimestamp!))
|
||||||
|
@ -184,9 +184,9 @@ public final class MessageSender : NSObject {
|
||||||
Configuration.shared.messageSenderDelegate.handleSuccessfulMessageSend(message, using: transaction)
|
Configuration.shared.messageSenderDelegate.handleSuccessfulMessageSend(message, using: transaction)
|
||||||
}, completion: { })
|
}, completion: { })
|
||||||
}
|
}
|
||||||
promise.catch(on: DispatchQueue.global(qos: .userInitiated)) { _ in
|
promise.catch(on: DispatchQueue.global(qos: .userInitiated)) { error in
|
||||||
storage.withAsync({ transaction in
|
storage.withAsync({ transaction in
|
||||||
Configuration.shared.messageSenderDelegate.handleFailedMessageSend(message, using: transaction)
|
Configuration.shared.messageSenderDelegate.handleFailedMessageSend(message, with: error, using: transaction)
|
||||||
}, completion: { })
|
}, completion: { })
|
||||||
}
|
}
|
||||||
return promise.map { _ in }
|
return promise.map { _ in }
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
public protocol MessageSenderDelegate {
|
public protocol MessageSenderDelegate {
|
||||||
|
|
||||||
func handleSuccessfulMessageSend(_ message: Message, using transaction: Any)
|
func handleSuccessfulMessageSend(_ message: Message, using transaction: Any)
|
||||||
func handleFailedMessageSend(_ message: Message, using transaction: Any)
|
func handleFailedMessageSend(_ message: Message, with error: Error, using transaction: Any)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,25 @@ extension Storage {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func cancelAllPendingJobs(of type: Job.Type, using transaction: YapDatabaseReadWriteTransaction) {
|
||||||
|
transaction.removeAllObjects(inCollection: type.collection)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func cancelPendingMessageSendJobs(for threadID: String, using transaction: YapDatabaseReadWriteTransaction) {
|
||||||
|
var attachmentUploadJobKeys: [String] = []
|
||||||
|
transaction.enumerateRows(inCollection: AttachmentUploadJob.collection) { key, object, _, _ in
|
||||||
|
guard let job = object as? AttachmentUploadJob, job.threadID == threadID else { return }
|
||||||
|
attachmentUploadJobKeys.append(key)
|
||||||
|
}
|
||||||
|
var messageSendJobKeys: [String] = []
|
||||||
|
transaction.enumerateRows(inCollection: MessageSendJob.collection) { key, object, _, _ in
|
||||||
|
guard let job = object as? MessageSendJob, job.message.threadID == threadID else { return }
|
||||||
|
messageSendJobKeys.append(key)
|
||||||
|
}
|
||||||
|
transaction.removeObjects(forKeys: attachmentUploadJobKeys, inCollection: AttachmentUploadJob.collection)
|
||||||
|
transaction.removeObjects(forKeys: messageSendJobKeys, inCollection: MessageSendJob.collection)
|
||||||
|
}
|
||||||
|
|
||||||
public func getAttachmentUploadJob(for attachmentID: String) -> AttachmentUploadJob? {
|
public func getAttachmentUploadJob(for attachmentID: String) -> AttachmentUploadJob? {
|
||||||
var result: [AttachmentUploadJob] = []
|
var result: [AttachmentUploadJob] = []
|
||||||
Storage.read { transaction in
|
Storage.read { transaction in
|
||||||
|
|
|
@ -40,8 +40,7 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value);
|
||||||
@property (nonatomic, readonly) uint64_t sortId;
|
@property (nonatomic, readonly) uint64_t sortId;
|
||||||
@property (nonatomic, readonly) uint64_t receivedAtTimestamp;
|
@property (nonatomic, readonly) uint64_t receivedAtTimestamp;
|
||||||
@property (nonatomic, readonly) BOOL shouldUseServerTime;
|
@property (nonatomic, readonly) BOOL shouldUseServerTime;
|
||||||
// Push notifications
|
@property (nonatomic, readonly) BOOL isOpenGroupMessage;
|
||||||
@property (nonatomic) BOOL hasUnfetchedAttachmentsFromPN;
|
|
||||||
|
|
||||||
- (void)setServerTimestampToReceivedTimestamp:(uint64_t)receivedAtTimestamp;
|
- (void)setServerTimestampToReceivedTimestamp:(uint64_t)receivedAtTimestamp;
|
||||||
|
|
||||||
|
|
|
@ -205,19 +205,18 @@ NSString *NSStringFromOWSInteractionType(OWSInteractionType value)
|
||||||
{
|
{
|
||||||
OWSAssertDebug(other);
|
OWSAssertDebug(other);
|
||||||
|
|
||||||
// Sort the messages by the sender's timestamp (Signal uses sortId)
|
uint64_t sortId1;
|
||||||
uint64_t sortId1 = self.timestamp;
|
uint64_t sortId2;
|
||||||
uint64_t sortId2 = other.timestamp;
|
|
||||||
|
|
||||||
// In open groups messages should be sorted by their server timestamp. `sortId` represents the order in which messages
|
// In open groups messages should be sorted by server timestamp. `sortId` represents the order in which messages
|
||||||
// were processed. Since in the open group poller we sort messages by their server timestamp, sorting by `sortId` is
|
// were processed. Since in the open group poller we sort messages by their server timestamp, sorting by `sortId` is
|
||||||
// effectively the same as sorting by server timestamp.
|
// effectively the same as sorting by server timestamp.
|
||||||
if (self.thread.isGroupThread) {
|
if (self.isOpenGroupMessage) {
|
||||||
TSGroupThread *thread = (TSGroupThread *)self.thread;
|
sortId1 = self.sortId;
|
||||||
if (thread.isOpenGroup) {
|
sortId2 = other.sortId;
|
||||||
sortId1 = self.sortId;
|
} else {
|
||||||
sortId2 = other.sortId;
|
sortId1 = self.timestamp;
|
||||||
}
|
sortId2 = other.timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sortId1 > sortId2) {
|
if (sortId1 > sortId2) {
|
||||||
|
|
|
@ -32,8 +32,9 @@ public final class MessageSenderDelegate : NSObject, SessionMessagingKit.Message
|
||||||
tsMessage.update(withSentRecipient: message.recipient!, wasSentByUD: true, transaction: transaction as! YapDatabaseReadWriteTransaction)
|
tsMessage.update(withSentRecipient: message.recipient!, wasSentByUD: true, transaction: transaction as! YapDatabaseReadWriteTransaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func handleFailedMessageSend(_ message: Message, using transaction: Any) {
|
public func handleFailedMessageSend(_ message: Message, with error: Swift.Error, using transaction: Any) {
|
||||||
// TODO: Implement
|
guard let tsMessage = TSOutgoingMessage.find(withTimestamp: message.sentTimestamp!) else { return }
|
||||||
|
tsMessage.update(sendingError: error, transaction: transaction as! YapDatabaseReadWriteTransaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Closed Groups
|
// MARK: Closed Groups
|
||||||
|
|
|
@ -282,8 +282,6 @@ typedef void (^AttachmentDownloadFailure)(NSError *error);
|
||||||
[job.attachmentPointer saveWithTransaction:transaction];
|
[job.attachmentPointer saveWithTransaction:transaction];
|
||||||
|
|
||||||
if (job.message) {
|
if (job.message) {
|
||||||
job.message.hasUnfetchedAttachmentsFromPN = !CurrentAppContext().isMainApp;
|
|
||||||
|
|
||||||
[job.message saveWithTransaction:transaction];
|
[job.message saveWithTransaction:transaction];
|
||||||
[job.message touchWithTransaction:transaction];
|
[job.message touchWithTransaction:transaction];
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,6 @@ static const NSUInteger kMaxPrekeyUpdateFailureCount = 5;
|
||||||
if (!keyId) {
|
if (!keyId) {
|
||||||
// currentSignedPreKeyId should only be nil before we've completed registration.
|
// currentSignedPreKeyId should only be nil before we've completed registration.
|
||||||
// We have this guard here for robustness, but we should never get here.
|
// We have this guard here for robustness, but we should never get here.
|
||||||
OWSFailDebug(@"Ignoring request to clear signed preKeys since no keyId was specified");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue