Merge branch 'charlesmchen/outgoingMessageState'

pull/1/head
Matthew Chen 8 years ago
commit f0727b541e

@ -138,7 +138,7 @@ CHECKOUT OPTIONS:
:commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308 :commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git :git: https://github.com/WhisperSystems/JSQMessagesViewController.git
SignalServiceKit: SignalServiceKit:
:commit: 91aeddf383ec50e70425103e80c1eb734b25fa53 :commit: bb24ffc917ddf41fa307d866a79f8ea76cb9ae05
:git: https://github.com/WhisperSystems/SignalServiceKit.git :git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket: SocketRocket:
:commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf

@ -191,11 +191,6 @@ NS_ASSUME_NONNULL_BEGIN
return NO; return NO;
} }
- (BOOL)isOutgoingAndDelivered
{
return NO;
}
- (NSUInteger)messageHash - (NSUInteger)messageHash
{ {
return self.hash; return self.hash;

@ -1,5 +1,6 @@
// Created by Michael Kirk on 9/26/16. //
// Copyright © 2016 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSMessageEditing.h" #import "OWSMessageEditing.h"
#import <JSQMessagesViewController/JSQMessageData.h> #import <JSQMessagesViewController/JSQMessageData.h>
@ -21,7 +22,6 @@ typedef NS_ENUM(NSInteger, TSMessageAdapterType) {
@property (nonatomic, readonly) TSMessageAdapterType messageType; @property (nonatomic, readonly) TSMessageAdapterType messageType;
@property (nonatomic, readonly) TSInteraction *interaction; @property (nonatomic, readonly) TSInteraction *interaction;
@property (nonatomic, readonly) BOOL isExpiringMessage; @property (nonatomic, readonly) BOOL isExpiringMessage;
@property (nonatomic, readonly) BOOL isOutgoingAndDelivered;
@property (nonatomic, readonly) BOOL shouldStartExpireTimer; @property (nonatomic, readonly) BOOL shouldStartExpireTimer;
@property (nonatomic, readonly) uint64_t expiresAtSeconds; @property (nonatomic, readonly) uint64_t expiresAtSeconds;
@property (nonatomic, readonly) uint32_t expiresInSeconds; @property (nonatomic, readonly) uint32_t expiresInSeconds;

@ -22,7 +22,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) TSInfoMessageType infoMessageType; @property (readonly) TSInfoMessageType infoMessageType;
@property (nonatomic, readonly) CGFloat mediaViewAlpha; @property (nonatomic, readonly) CGFloat mediaViewAlpha;
@property (nonatomic, readonly) BOOL isMediaBeingSent; @property (nonatomic, readonly) BOOL isMediaBeingSent;
@property (nonatomic, readonly) BOOL isOutgoingAndDelivered;
@end @end

@ -383,17 +383,6 @@ NS_ASSUME_NONNULL_BEGIN
return NO; return NO;
} }
- (BOOL)isOutgoingAndDelivered
{
if ([self.interaction isKindOfClass:[TSOutgoingMessage class]]) {
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.interaction;
if (outgoingMessage.messageState == TSOutgoingMessageStateDelivered) {
return YES;
}
}
return NO;
}
#pragma mark - Logging #pragma mark - Logging
+ (NSString *)tag + (NSString *)tag

@ -1183,7 +1183,11 @@ typedef enum : NSUInteger {
return self.outgoingMessageFailedImageData; return self.outgoingMessageFailedImageData;
case TSOutgoingMessageStateAttemptingOut: case TSOutgoingMessageStateAttemptingOut:
return self.currentlyOutgoingBubbleImageData; return self.currentlyOutgoingBubbleImageData;
default: case TSOutgoingMessageStateSent_OBSOLETE:
case TSOutgoingMessageStateDelivered_OBSOLETE:
OWSAssert(0);
return self.outgoingBubbleImageData;
case TSOutgoingMessageStateSentToService:
return self.outgoingBubbleImageData; return self.outgoingBubbleImageData;
} }
} }
@ -1490,13 +1494,10 @@ typedef enum : NSUInteger {
if (outgoingMessage.messageState == TSOutgoingMessageStateUnsent) { if (outgoingMessage.messageState == TSOutgoingMessageStateUnsent) {
return [[NSAttributedString alloc] initWithString:NSLocalizedString(@"MESSAGE_STATUS_FAILED", return [[NSAttributedString alloc] initWithString:NSLocalizedString(@"MESSAGE_STATUS_FAILED",
@"message footer for failed messages")]; @"message footer for failed messages")];
} else if (outgoingMessage.messageState == TSOutgoingMessageStateSent || } else if (outgoingMessage.messageState == TSOutgoingMessageStateSentToService) {
outgoingMessage.messageState == TSOutgoingMessageStateDelivered) { NSString *text = (outgoingMessage.wasDelivered
NSString *text = (outgoingMessage.messageState == TSOutgoingMessageStateSent ? NSLocalizedString(@"MESSAGE_STATUS_DELIVERED", @"message footer for delivered messages")
? NSLocalizedString(@"MESSAGE_STATUS_SENT", : NSLocalizedString(@"MESSAGE_STATUS_SENT", @"message footer for sent messages"));
@"message footer for sent messages")
: NSLocalizedString(@"MESSAGE_STATUS_DELIVERED",
@"message footer for delivered messages"));
NSAttributedString *result = [[NSAttributedString alloc] initWithString:text]; NSAttributedString *result = [[NSAttributedString alloc] initWithString:text];
// Show when it's the last message in the thread // Show when it's the last message in the thread
@ -1507,9 +1508,7 @@ typedef enum : NSUInteger {
// Or when the next message is *not* an outgoing sent/delivered message. // Or when the next message is *not* an outgoing sent/delivered message.
TSOutgoingMessage *nextMessage = [self nextOutgoingMessage:indexPath]; TSOutgoingMessage *nextMessage = [self nextOutgoingMessage:indexPath];
if (nextMessage && if (nextMessage && nextMessage.messageState != TSOutgoingMessageStateSentToService) {
nextMessage.messageState != TSOutgoingMessageStateSent &&
nextMessage.messageState != TSOutgoingMessageStateDelivered) {
[self updateLastDeliveredMessage:message]; [self updateLastDeliveredMessage:message];
return result; return result;
} }
@ -2320,22 +2319,6 @@ typedef enum : NSUInteger {
(unsigned long)attachment.data.length, (unsigned long)attachment.data.length,
[attachment mimeType]); [attachment mimeType]);
[ThreadUtil sendMessageWithAttachment:attachment inThread:self.thread messageSender:self.messageSender]; [ThreadUtil sendMessageWithAttachment:attachment inThread:self.thread messageSender:self.messageSender];
TSOutgoingMessage *message;
OWSDisappearingMessagesConfiguration *configuration =
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:self.thread.uniqueId];
if (configuration.isEnabled) {
message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:self.thread
messageBody:nil
attachmentIds:[NSMutableArray new]
expiresInSeconds:configuration.durationSeconds];
} else {
message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:self.thread
messageBody:nil
attachmentIds:[NSMutableArray new]];
}
} }
- (NSURL *)videoTempFolder { - (NSURL *)videoTempFolder {
@ -2703,10 +2686,8 @@ typedef enum : NSUInteger {
[groupThread saveWithTransaction:transaction]; [groupThread saveWithTransaction:transaction];
message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:groupThread inThread:groupThread
messageBody:@"" groupMetaMessage:TSGroupMessageUpdate];
attachmentIds:[NSMutableArray new]]; [message updateWithCustomMessage:updateGroupInfo transaction:transaction];
message.groupMetaMessage = TSGroupMessageUpdate;
message.customMessage = updateGroupInfo;
}]; }];
if (newGroupModel.groupImage) { if (newGroupModel.groupImage) {

@ -309,11 +309,10 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
TSOutgoingMessage *message = TSOutgoingMessage *message =
[[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:self.thread inThread:self.thread
messageBody:@"" groupMetaMessage:TSGroupMessageNew];
attachmentIds:[NSMutableArray new]];
message.groupMetaMessage = TSGroupMessageNew; // This will save the message.
message.customMessage = NSLocalizedString(@"GROUP_CREATED", nil); [message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)];
if (model.groupImage) { if (model.groupImage) {
[self.messageSender sendAttachmentData:UIImagePNGRepresentation(model.groupImage) [self.messageSender sendAttachmentData:UIImagePNGRepresentation(model.groupImage)
contentType:OWSMimeTypeImagePng contentType:OWSMimeTypeImagePng

@ -398,8 +398,7 @@ static NSString *const OWSConversationSettingsTableViewControllerSegueShowGroupM
TSGroupThread *gThread = (TSGroupThread *)self.thread; TSGroupThread *gThread = (TSGroupThread *)self.thread;
TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:gThread inThread:gThread
messageBody:@""]; groupMetaMessage:TSGroupMessageQuit];
message.groupMetaMessage = TSGroupMessageQuit;
[self.messageSender sendMessage:message [self.messageSender sendMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully left group.", self.tag); DDLogInfo(@"%@ Successfully left group.", self.tag);

@ -460,9 +460,7 @@ NSString *const SignalsViewControllerSegueShowIncomingCall = @"ShowIncomingCallS
TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread inThread:thread
messageBody:@"" groupMetaMessage:TSGroupMessageQuit];
attachmentIds:[NSMutableArray new]];
message.groupMetaMessage = TSGroupMessageQuit;
[self.messageSender sendMessage:message [self.messageSender sendMessage:message
success:^{ success:^{
[self dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES

@ -25,21 +25,14 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(thread); OWSAssert(thread);
OWSAssert(messageSender); OWSAssert(messageSender);
TSOutgoingMessage *message;
OWSDisappearingMessagesConfiguration *configuration = OWSDisappearingMessagesConfiguration *configuration =
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId]; [OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId];
if (configuration.isEnabled) { TSOutgoingMessage *message =
message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread inThread:thread
messageBody:text messageBody:text
attachmentIds:[NSMutableArray new] attachmentIds:[NSMutableArray new]
expiresInSeconds:configuration.durationSeconds]; expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)];
} else {
message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread
messageBody:text];
}
[messageSender sendMessage:message [messageSender sendMessage:message
success:^{ success:^{
DDLogInfo(@"%@ Successfully sent message.", self.tag); DDLogInfo(@"%@ Successfully sent message.", self.tag);
@ -61,22 +54,14 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(thread); OWSAssert(thread);
OWSAssert(messageSender); OWSAssert(messageSender);
TSOutgoingMessage *message;
OWSDisappearingMessagesConfiguration *configuration = OWSDisappearingMessagesConfiguration *configuration =
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId]; [OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId];
if (configuration.isEnabled) { TSOutgoingMessage *message =
message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread inThread:thread
messageBody:nil messageBody:nil
attachmentIds:[NSMutableArray new] attachmentIds:[NSMutableArray new]
expiresInSeconds:configuration.durationSeconds]; expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)];
} else {
message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread
messageBody:nil
attachmentIds:[NSMutableArray new]];
}
[messageSender sendAttachmentData:attachment.data [messageSender sendAttachmentData:attachment.data
contentType:attachment.mimeType contentType:attachment.mimeType
filename:attachment.filename filename:attachment.filename

@ -343,6 +343,9 @@
/* Generic error used whenver Signal can't contact the server */ /* Generic error used whenver Signal can't contact the server */
"ERROR_DESCRIPTION_NO_INTERNET" = "Signal was unable to connect to the internet. Please try from another WiFi network or use mobile data."; "ERROR_DESCRIPTION_NO_INTERNET" = "Signal was unable to connect to the internet. Please try from another WiFi network or use mobile data.";
/* Error indicating that an outgoing message had no valid recipients. */
"ERROR_DESCRIPTION_NO_VALID_RECIPIENTS" = "Message send failed due to a lack of valid recipients.";
/* Error message when attempting to send message */ /* Error message when attempting to send message */
"ERROR_DESCRIPTION_SENDING_UNAUTHORIZED" = "Your device is no longer registered for your phone number. You must remove and reinstall Signal."; "ERROR_DESCRIPTION_SENDING_UNAUTHORIZED" = "Your device is no longer registered for your phone number. You must remove and reinstall Signal.";

Loading…
Cancel
Save