Group updates can be deleted

Removed some dead code re: NSCopy/Coding, since it seems unused.

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent 07ab1bd931
commit 89df8ddb31

@ -2,11 +2,11 @@
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved. // Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved.
#import "OWSMessageData.h" #import "OWSMessageData.h"
#import "TSMessageAdapter.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class TSCall; @class TSCall;
@class TSInteraction;
typedef enum : NSUInteger { typedef enum : NSUInteger {
kCallOutgoing = 1, kCallOutgoing = 1,
@ -17,17 +17,18 @@ typedef enum : NSUInteger {
kGroupUpdate = 6 kGroupUpdate = 6
} CallStatus; } CallStatus;
@interface OWSCall : NSObject <OWSMessageData, NSCoding, NSCopying> @interface OWSCall : NSObject <OWSMessageData>
#pragma mark - Initialization #pragma mark - Initialization
- (instancetype)initWithCallRecord:(TSCall *)callRecord; - (instancetype)initWithCallRecord:(TSCall *)callRecord;
- (instancetype)initWithCallerId:(NSString *)callerId - (instancetype)initWithInteraction:(TSInteraction *)interaction
callerDisplayName:(NSString *)callerDisplayName callerId:(NSString *)senderId
date:(nullable NSDate *)date callerDisplayName:(NSString *)senderDisplayName
status:(CallStatus)status date:(nullable NSDate *)date
displayString:(NSString *)detailString NS_DESIGNATED_INITIALIZER; status:(CallStatus)status
displayString:(NSString *)detailString NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;

@ -36,7 +36,6 @@ NS_ASSUME_NONNULL_BEGIN
DDLogError(@"%@ Unexpected thread type: %@", self.tag, thread); DDLogError(@"%@ Unexpected thread type: %@", self.tag, thread);
} }
CallStatus status = 0; CallStatus status = 0;
switch (callRecord.callType) { switch (callRecord.callType) {
case RPRecentCallTypeOutgoing: case RPRecentCallTypeOutgoing:
@ -70,26 +69,20 @@ NS_ASSUME_NONNULL_BEGIN
break; break;
} }
self = [self initWithCallerId:contactThread.contactIdentifier return [self initWithInteraction:callRecord
callerDisplayName:name callerId:contactThread.contactIdentifier
date:callRecord.date callerDisplayName:name
status:status date:callRecord.date
displayString:detailString]; status:status
displayString:detailString];
if (!self) {
return self;
}
_interaction = callRecord;
return self;
} }
- (instancetype)initWithCallerId:(NSString *)senderId - (instancetype)initWithInteraction:(TSInteraction *)interaction
callerDisplayName:(NSString *)senderDisplayName callerId:(NSString *)senderId
date:(nullable NSDate *)date callerDisplayName:(NSString *)senderDisplayName
status:(CallStatus)status date:(nullable NSDate *)date
displayString:(NSString *)detailString status:(CallStatus)status
displayString:(NSString *)detailString
{ {
NSParameterAssert(senderId != nil); NSParameterAssert(senderId != nil);
NSParameterAssert(senderDisplayName != nil); NSParameterAssert(senderDisplayName != nil);
@ -99,6 +92,7 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
_interaction = interaction;
_senderId = [senderId copy]; _senderId = [senderId copy];
_senderDisplayName = [senderDisplayName copy]; _senderDisplayName = [senderDisplayName copy];
_date = [date copy]; _date = [date copy];
@ -184,42 +178,6 @@ NS_ASSUME_NONNULL_BEGIN
return NO; return NO;
} }
#pragma mark - NSCoding
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder
{
NSString *senderId = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(senderId))];
NSString *senderDisplayName = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(senderDisplayName))];
NSDate *date = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(date))];
CallStatus status = (CallStatus)[aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(status))];
NSString *displayString = @""; // FIXME what should this be?
return [self initWithCallerId:senderId
callerDisplayName:senderDisplayName
date:date
status:status
displayString:displayString];
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:self.senderId forKey:NSStringFromSelector(@selector(senderId))];
[aCoder encodeObject:self.senderDisplayName forKey:NSStringFromSelector(@selector(senderDisplayName))];
[aCoder encodeObject:self.date forKey:NSStringFromSelector(@selector(date))];
[aCoder encodeDouble:self.status forKey:NSStringFromSelector(@selector(status))];
}
#pragma mark - NSCopying
- (instancetype)copyWithZone:(nullable NSZone *)zone
{
return [[[self class] allocWithZone:zone] initWithCallerId:self.senderId
callerDisplayName:self.senderDisplayName
date:self.date
status:self.status
displayString:self.detailString];
}
- (NSUInteger)messageHash - (NSUInteger)messageHash
{ {
return self.hash; return self.hash;

@ -186,11 +186,12 @@
} else if (adapter.infoMessageType == TSInfoMessageTypeGroupUpdate) { } else if (adapter.infoMessageType == TSInfoMessageTypeGroupUpdate) {
status = kGroupUpdate; status = kGroupUpdate;
} }
OWSCall *call = [[OWSCall alloc] initWithCallerId:@"" OWSCall *call = [[OWSCall alloc] initWithInteraction:interaction
callerDisplayName:adapter.messageBody callerId:@""
date:nil callerDisplayName:adapter.messageBody
status:status date:nil
displayString:@""]; status:status
displayString:@""];
return call; return call;
} }
} else { } else {

Loading…
Cancel
Save