mirror of https://github.com/oxen-io/session-ios
parent
766e579961
commit
cd440b839f
@ -1,16 +0,0 @@
|
||||
//
|
||||
// OWSContactsSearcher.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Michael Kirk on 6/27/16.
|
||||
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Contact.h"
|
||||
|
||||
@interface OWSContactsSearcher : NSObject
|
||||
|
||||
- (instancetype)initWithContacts:(NSArray<Contact *> *)contacts;
|
||||
- (NSArray<Contact *> *)filterWithString:(NSString *)string;
|
||||
|
||||
@end
|
@ -1,40 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSContactsSearcher.h"
|
||||
#import "NSString+OWS.h"
|
||||
#import <SignalServiceKit/PhoneNumber.h>
|
||||
|
||||
@interface OWSContactsSearcher ()
|
||||
|
||||
@property (copy) NSArray<Contact *> *contacts;
|
||||
|
||||
@end
|
||||
|
||||
@implementation OWSContactsSearcher
|
||||
|
||||
- (instancetype)initWithContacts:(NSArray<Contact *> *)contacts {
|
||||
self = [super init];
|
||||
if (!self) return self;
|
||||
|
||||
_contacts = contacts;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSArray<Contact *> *)filterWithString:(NSString *)string {
|
||||
NSString *searchTerm = [string ows_stripped];
|
||||
|
||||
if ([searchTerm isEqualToString:@""]) {
|
||||
return self.contacts;
|
||||
}
|
||||
|
||||
NSString *formattedNumber = [PhoneNumber removeFormattingCharacters:searchTerm];
|
||||
|
||||
// TODO: This assumes there's a single search term.
|
||||
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(fullName contains[c] %@) OR (ANY parsedPhoneNumbers.toE164 contains[c] %@)", searchTerm, formattedNumber];
|
||||
|
||||
return [self.contacts filteredArrayUsingPredicate:predicate];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue