|
|
@ -370,12 +370,12 @@ typedef enum : NSUInteger {
|
|
|
|
name:NSNotification.groupThreadUpdated
|
|
|
|
name:NSNotification.groupThreadUpdated
|
|
|
|
object:nil];
|
|
|
|
object:nil];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
selector:@selector(handleCalculatingPoWNotification:)
|
|
|
|
selector:@selector(handleEncryptingMessageNotification:)
|
|
|
|
name:NSNotification.calculatingMessagePoW
|
|
|
|
name:NSNotification.encryptingMessage
|
|
|
|
object:nil];
|
|
|
|
object:nil];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
selector:@selector(handleRoutingNotification:)
|
|
|
|
selector:@selector(handleCalculatingMessagePoWNotification:)
|
|
|
|
name:NSNotification.encryptingMessage
|
|
|
|
name:NSNotification.calculatingMessagePoW
|
|
|
|
object:nil];
|
|
|
|
object:nil];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
selector:@selector(handleMessageSendingNotification:)
|
|
|
|
selector:@selector(handleMessageSendingNotification:)
|
|
|
@ -386,7 +386,7 @@ typedef enum : NSUInteger {
|
|
|
|
name:NSNotification.messageSent
|
|
|
|
name:NSNotification.messageSent
|
|
|
|
object:nil];
|
|
|
|
object:nil];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
selector:@selector(handleMessageFailedNotification:)
|
|
|
|
selector:@selector(handleMessageSendingFailedNotification:)
|
|
|
|
name:NSNotification.messageSendingFailed
|
|
|
|
name:NSNotification.messageSendingFailed
|
|
|
|
object:nil];
|
|
|
|
object:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -3816,16 +3816,10 @@ typedef enum : NSUInteger {
|
|
|
|
|
|
|
|
|
|
|
|
text = [text ows_stripped];
|
|
|
|
text = [text ows_stripped];
|
|
|
|
|
|
|
|
|
|
|
|
if (text.length < 1) {
|
|
|
|
if (text.length < 1) { return; }
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Limit outgoing text messages to 16kb.
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// We convert large text messages to attachments
|
|
|
|
|
|
|
|
// which are presented as normal text messages.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SNVisibleMessage *message = [SNVisibleMessage new];
|
|
|
|
SNVisibleMessage *message = [SNVisibleMessage new];
|
|
|
|
|
|
|
|
[message setSentTimestamp:[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) {
|
|
|
|
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
@ -3834,29 +3828,18 @@ typedef enum : NSUInteger {
|
|
|
|
|
|
|
|
|
|
|
|
TSOutgoingMessage *tsMessage = [TSOutgoingMessage from:message associatedWith:self.thread];
|
|
|
|
TSOutgoingMessage *tsMessage = [TSOutgoingMessage from:message associatedWith:self.thread];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[tsMessage save];
|
|
|
|
|
|
|
|
|
|
|
|
[self.conversationViewModel appendUnsavedOutgoingTextMessage:tsMessage];
|
|
|
|
[self.conversationViewModel appendUnsavedOutgoingTextMessage:tsMessage];
|
|
|
|
|
|
|
|
|
|
|
|
[self messageWasSent:tsMessage];
|
|
|
|
[self messageWasSent:tsMessage];
|
|
|
|
|
|
|
|
|
|
|
|
// Clearing the text message is a key part of the send animation.
|
|
|
|
|
|
|
|
// It takes 10-15ms, but we do it inline rather than dispatch async
|
|
|
|
|
|
|
|
// since the send can't feel "complete" without it.
|
|
|
|
|
|
|
|
[BenchManager benchWithTitle:@"clearTextMessageAnimated"
|
|
|
|
|
|
|
|
block:^{
|
|
|
|
|
|
|
|
[self.inputToolbar clearTextMessageAnimated:YES];
|
|
|
|
[self.inputToolbar clearTextMessageAnimated:YES];
|
|
|
|
|
|
|
|
|
|
|
|
[self resetMentions];
|
|
|
|
[self resetMentions];
|
|
|
|
}];
|
|
|
|
|
|
|
|
[BenchManager completeEventWithEventId:@"fromSendUntil_clearTextMessageAnimated"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
// After sending we want to return from the numeric keyboard to the
|
|
|
|
|
|
|
|
// alphabetical one. Because this is so slow (40-50ms), we prefer it
|
|
|
|
|
|
|
|
// happens async, after any more essential send UI work is done.
|
|
|
|
|
|
|
|
[BenchManager benchWithTitle:@"toggleDefaultKeyboard"
|
|
|
|
|
|
|
|
block:^{
|
|
|
|
|
|
|
|
[self.inputToolbar toggleDefaultKeyboard];
|
|
|
|
[self.inputToolbar toggleDefaultKeyboard];
|
|
|
|
}];
|
|
|
|
|
|
|
|
[BenchManager completeEventWithEventId:@"fromSendUntil_toggleDefaultKeyboard"];
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
|
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
|
|
@ -4554,13 +4537,13 @@ typedef enum : NSUInteger {
|
|
|
|
[self updateScrollDownButtonLayout];
|
|
|
|
[self updateScrollDownButtonLayout];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)handleCalculatingPoWNotification:(NSNotification *)notification
|
|
|
|
- (void)handleEncryptingMessageNotification:(NSNotification *)notification
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NSNumber *timestamp = (NSNumber *)notification.object;
|
|
|
|
NSNumber *timestamp = (NSNumber *)notification.object;
|
|
|
|
[self setProgressIfNeededTo:0.25f forMessageWithTimestamp:timestamp];
|
|
|
|
[self setProgressIfNeededTo:0.25f forMessageWithTimestamp:timestamp];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)handleRoutingNotification:(NSNotification *)notification
|
|
|
|
- (void)handleCalculatingMessagePoWNotification:(NSNotification *)notification
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NSNumber *timestamp = (NSNumber *)notification.object;
|
|
|
|
NSNumber *timestamp = (NSNumber *)notification.object;
|
|
|
|
[self setProgressIfNeededTo:0.50f forMessageWithTimestamp:timestamp];
|
|
|
|
[self setProgressIfNeededTo:0.50f forMessageWithTimestamp:timestamp];
|
|
|
@ -4582,7 +4565,7 @@ typedef enum : NSUInteger {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)handleMessageFailedNotification:(NSNotification *)notification
|
|
|
|
- (void)handleMessageSendingFailedNotification:(NSNotification *)notification
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NSNumber *timestamp = (NSNumber *)notification.object;
|
|
|
|
NSNumber *timestamp = (NSNumber *)notification.object;
|
|
|
|
[self hideProgressIndicatorViewForMessageWithTimestamp:timestamp];
|
|
|
|
[self hideProgressIndicatorViewForMessageWithTimestamp:timestamp];
|
|
|
@ -4590,11 +4573,7 @@ typedef enum : NSUInteger {
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setProgressIfNeededTo:(float)progress forMessageWithTimestamp:(NSNumber *)timestamp
|
|
|
|
- (void)setProgressIfNeededTo:(float)progress forMessageWithTimestamp:(NSNumber *)timestamp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ([self.handledMessageTimestamps contains:^BOOL(NSNumber *t) {
|
|
|
|
if ([self.handledMessageTimestamps containsObject:timestamp]) { return; }
|
|
|
|
return [t isEqual:timestamp];
|
|
|
|
|
|
|
|
}]) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
__block TSInteraction *targetInteraction;
|
|
|
|
__block TSInteraction *targetInteraction;
|
|
|
|
[LKStorage readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|
[LKStorage readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
|
|
|