Hook up public key checking

pull/7/head
Niels Andriesse 6 years ago
parent 4ce9228afd
commit 4c7e653cef

@ -398,18 +398,24 @@ NS_ASSUME_NONNULL_BEGIN
// Loki: // Loki:
// ======== // ========
NSString *publicKey = self.searchBar.text; NSString *publicKey = self.searchBar.text;
BOOL isValid = [ECKeyPair isValidHexEncodedPublicKeyWithCandidate:publicKey];
// TODO: Validate public key and show an error if something's wrong if (!isValid) {
OWSTableSection *invalidPublicKeySection = [OWSTableSection new];
OWSTableSection *newConversationSection = [OWSTableSection new]; [invalidPublicKeySection
[newConversationSection addItem:[OWSTableItem softCenterLabelItemWithText:NSLocalizedString(@"Invalid public key", @"")
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"Start a Conversation", @"") customRowHeight:UITableViewAutomaticDimension]];
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"start_conversation") [contents addSection:invalidPublicKeySection];
customRowHeight:UITableViewAutomaticDimension } else {
actionBlock:^{ OWSTableSection *newConversationSection = [OWSTableSection new];
[weakSelf newConversationWithRecipientId:publicKey]; [newConversationSection
}]]; addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"Start a Conversation", @"")
[contents addSection:newConversationSection]; accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"start_conversation")
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{
[weakSelf newConversationWithRecipientId:publicKey];
}]];
[contents addSection:newConversationSection];
}
// ======== // ========
for (OWSTableSection *section in [self contactsSectionsForSearch]) { for (OWSTableSection *section in [self contactsSectionsForSearch]) {
[contents addSection:section]; [contents addSection:section];
@ -728,13 +734,18 @@ NS_ASSUME_NONNULL_BEGIN
[sections addObject:inviteeSection]; [sections addObject:inviteeSection];
} }
// Loki:
// ========
NSString *publicKey = self.searchBar.text;
BOOL isValidPublicKey = [ECKeyPair isValidHexEncodedPublicKeyWithCandidate:publicKey];
// ========
if (!hasSearchResults) { if (isValidPublicKey && !hasSearchResults) {
// No Search Results // No Search Results
OWSTableSection *noResultsSection = [OWSTableSection new]; OWSTableSection *noResultsSection = [OWSTableSection new];
[noResultsSection [noResultsSection
addItem:[OWSTableItem softCenterLabelItemWithText: addItem:[OWSTableItem softCenterLabelItemWithText:
NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_SEARCH_RESULTS", NSLocalizedString(@"No search results",
@"A label that indicates the user's search has no matching results.") @"A label that indicates the user's search has no matching results.")
customRowHeight:UITableViewAutomaticDimension]]; customRowHeight:UITableViewAutomaticDimension]];

@ -2566,3 +2566,5 @@
"Your mnemonic couldn't be verified. Please check what you entered and try again." = "Your mnemonic couldn't be verified. Please check what you entered and try again."; "Your mnemonic couldn't be verified. Please check what you entered and try again." = "Your mnemonic couldn't be verified. Please check what you entered and try again.";
"Search by name or public key" = "Search by name or public key"; "Search by name or public key" = "Search by name or public key";
"Start a Conversation" = "Start a Conversation"; "Start a Conversation" = "Start a Conversation";
"Invalid public key" = "Invalid public key";
"No search results" = "No search results";

Loading…
Cancel
Save