Add SignalAccount class.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent cd9e1fb574
commit 5058eb837e

@ -29,6 +29,7 @@ typedef NS_ENUM(NSUInteger, OWSPhoneNumberType) {
@class PhoneNumber; @class PhoneNumber;
@class UIImage; @class UIImage;
@class SignalRecipient; @class SignalRecipient;
@class YapDatabaseReadTransaction;
@interface Contact : NSObject @interface Contact : NSObject
@ -48,7 +49,7 @@ typedef NS_ENUM(NSUInteger, OWSPhoneNumberType) {
#endif // TARGET_OS_IOS #endif // TARGET_OS_IOS
- (BOOL)isSignalContact; - (BOOL)isSignalContact;
- (NSArray<SignalRecipient *> *)signalRecipients; - (NSArray<SignalRecipient *> *)signalRecipientsWithTransaction:(YapDatabaseReadTransaction *)transaction;
// TODO: Remove this method. // TODO: Remove this method.
- (NSArray<NSString *> *)textSecureIdentifiers; - (NSArray<NSString *> *)textSecureIdentifiers;

@ -202,19 +202,18 @@ NS_ASSUME_NONNULL_BEGIN
return [identifiers count] > 0; return [identifiers count] > 0;
} }
- (NSArray<SignalRecipient *> *)signalRecipients - (NSArray<SignalRecipient *> *)signalRecipientsWithTransaction:(YapDatabaseReadTransaction *)transaction
{ {
__block NSMutableArray *result = [NSMutableArray array]; __block NSMutableArray *result = [NSMutableArray array];
[[TSStorageManager sharedManager].dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { for (PhoneNumber *number in [self.parsedPhoneNumbers sortedArrayUsingSelector:@selector(compare:)]) {
for (PhoneNumber *number in [self.parsedPhoneNumbers sortedArrayUsingSelector:@selector(compare:)]) { SignalRecipient *signalRecipient =
SignalRecipient *signalRecipient = [SignalRecipient recipientWithTextSecureIdentifier:number.toE164 withTransaction:transaction];
[SignalRecipient recipientWithTextSecureIdentifier:number.toE164 withTransaction:transaction]; if (signalRecipient) {
if (signalRecipient) { [result addObject:signalRecipient];
[result addObject:signalRecipient];
}
} }
}]; }
return [result copy]; return [result copy];
} }

@ -27,6 +27,10 @@ NS_ASSUME_NONNULL_BEGIN
// This property indicates support for both WebRTC audio and video calls. // This property indicates support for both WebRTC audio and video calls.
- (BOOL)supportsWebRTC; - (BOOL)supportsWebRTC;
- (NSString *)recipientId;
- (NSComparisonResult)compare:(SignalRecipient *)other;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -83,6 +83,16 @@ NS_ASSUME_NONNULL_BEGIN
return YES; return YES;
} }
- (NSString *)recipientId
{
return self.uniqueId;
}
- (NSComparisonResult)compare:(SignalRecipient *)other
{
return [self.recipientId compare:other.recipientId];
}
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

Loading…
Cancel
Save