Groups: Name of leaving user + outgoing message layout.

This commit is contained in:
Frederic Jacobs 2014-12-29 11:20:20 +01:00
parent e58f9bf966
commit a93b111458
4 changed files with 11 additions and 4 deletions

View file

@ -87,5 +87,4 @@ andCurrentRegionCodeForPhoneNumbers:(NSString*)currentRegionCodeForPhoneNumbers
+ (void)messageIdentifier:(NSString*)identifier; + (void)messageIdentifier:(NSString*)identifier;
+ (void)groupModel:(GroupModel*)model; + (void)groupModel:(GroupModel*)model;
@end @end

View file

@ -35,6 +35,7 @@
#import "Environment.h" #import "Environment.h"
#import "PreferencesUtil.h" #import "PreferencesUtil.h"
#import "ContactsManager.h"
#import <CocoaLumberjack/DDLog.h> #import <CocoaLumberjack/DDLog.h>
@ -255,10 +256,17 @@
[[[TSInfoMessage alloc] initWithTimestamp:timeStamp inThread:gThread messageType:TSInfoMessageTypeGroupUpdate customMessage:updateGroupInfo] saveWithTransaction:transaction]; [[[TSInfoMessage alloc] initWithTimestamp:timeStamp inThread:gThread messageType:TSInfoMessageTypeGroupUpdate customMessage:updateGroupInfo] saveWithTransaction:transaction];
} }
else if(content.group.type==PushMessageContentGroupContextTypeQuit) { else if(content.group.type==PushMessageContentGroupContextTypeQuit) {
NSString* updateGroupInfo = [NSString stringWithFormat:@"%@ has left group",message.source]; NSString *nameString = [[Environment.getCurrent contactsManager] nameStringForPhoneIdentifier:message.source];
if (!nameString) {
nameString = message.source;
}
NSString* updateGroupInfo = [NSString stringWithFormat:@"%@ has left group",nameString];
NSMutableArray *newGroupMembers = [NSMutableArray arrayWithArray:gThread.groupModel.groupMemberIds]; NSMutableArray *newGroupMembers = [NSMutableArray arrayWithArray:gThread.groupModel.groupMemberIds];
[newGroupMembers removeObject:message.source]; [newGroupMembers removeObject:message.source];
gThread.groupModel.groupMemberIds = newGroupMembers; gThread.groupModel.groupMemberIds = newGroupMembers;
[gThread saveWithTransaction:transaction]; [gThread saveWithTransaction:transaction];
[[[TSInfoMessage alloc] initWithTimestamp:timeStamp inThread:gThread messageType:TSInfoMessageTypeGroupUpdate customMessage:updateGroupInfo] saveWithTransaction:transaction]; [[[TSInfoMessage alloc] initWithTimestamp:timeStamp inThread:gThread messageType:TSInfoMessageTypeGroupUpdate customMessage:updateGroupInfo] saveWithTransaction:transaction];
} }

View file

@ -110,7 +110,6 @@ typedef enum : NSUInteger {
- (void)setupWithThread:(TSThread *)thread{ - (void)setupWithThread:(TSThread *)thread{
self.thread = thread; self.thread = thread;
isGroupConversation = [self.thread isKindOfClass:[TSGroupThread class]]; isGroupConversation = [self.thread isKindOfClass:[TSGroupThread class]];
} }
- (void)viewDidLoad { - (void)viewDidLoad {
@ -1027,7 +1026,6 @@ typedef enum : NSUInteger {
} }
- (IBAction)unwindGroupUpdated:(UIStoryboardSegue *)segue{ - (IBAction)unwindGroupUpdated:(UIStoryboardSegue *)segue{
[self.inputToolbar.contentView.textView resignFirstResponder]; [self.inputToolbar.contentView.textView resignFirstResponder];
NewGroupViewController *ngc = [segue sourceViewController]; NewGroupViewController *ngc = [segue sourceViewController];

View file

@ -79,9 +79,11 @@
TSIncomingMessage *message = (TSIncomingMessage*)interaction; TSIncomingMessage *message = (TSIncomingMessage*)interaction;
adapter.senderId = message.authorId; adapter.senderId = message.authorId;
adapter.senderDisplayName = message.authorId; adapter.senderDisplayName = message.authorId;
adapter.messageType = TSIncomingMessageAdapter;
} else { } else {
adapter.senderId = ME_MESSAGE_IDENTIFIER; adapter.senderId = ME_MESSAGE_IDENTIFIER;
adapter.senderDisplayName = @"Me"; adapter.senderDisplayName = @"Me";
adapter.messageType = TSOutgoingMessageAdapter;
} }
} }