Cap number of devices on both ends

This commit is contained in:
Niels Andriesse 2019-11-18 13:45:45 +11:00
parent f74ebae588
commit acb5b7407d
3 changed files with 17 additions and 2 deletions

View File

@ -359,7 +359,7 @@ final class SeedVC : OnboardingBaseViewController, DeviceLinkingModalDelegate {
}.catch(on: DispatchQueue.main) { [weak self] _ in
TSAccountManager.sharedInstance().resetForReregistration()
guard let self = self else { return }
let alert = UIAlertController(title: "Couldn't Link Device", message: "Please check your connection and try again.", preferredStyle: .alert)
let alert = UIAlertController(title: NSLocalizedString("Couldn't Link Device", comment: ""), message: NSLocalizedString("Please check your connection and try again.", comment: ""), preferredStyle: .alert)
self.present(alert, animated: true, completion: nil)
self.setUserInteractionEnabled(true)
}

View File

@ -249,9 +249,22 @@
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Share Public Key", @"") actionBlock:^{ [weakSelf sharePublicKey]; }]];
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Show QR Code", @"") actionBlock:^{ [weakSelf showQRCode]; }]];
if (isMasterDevice) {
NSString *userHexEncodedPublicKey = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey;
__block BOOL hasLinkedDevice;
[OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
NSSet<LKDeviceLink *> *deviceLinks = [LKDatabaseUtilities getDeviceLinksFor:userHexEncodedPublicKey in:transaction];
hasLinkedDevice = deviceLinks.count > 0;
}];
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Link Device", @"") actionBlock:^{
[weakSelf linkDevice];
if (!hasLinkedDevice) {
[weakSelf linkDevice];
} else {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Multi Device Limit Reached", @"") message:NSLocalizedString(@"It's currently not allowed to link more than one device.", @"") preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") style:UIAlertActionStyleDefault handler:nil]];
[weakSelf presentViewController:alert animated:YES completion:nil];
}
}]];
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Show Seed", @"") actionBlock:^{ [weakSelf showSeed]; }]];
}
[section addItem:[OWSTableItem itemWithTitle:NSLocalizedString(@"Clear All Data", @"") actionBlock:^{ [weakSelf clearAllData]; }]];

View File

@ -2648,3 +2648,5 @@
"Connecting..." = "Connecting...";
"Couldn't Connect" = "Couldn't Connect";
"Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters" = "Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters";
"Multi Device Limit Reached" = "Multi Device Limit Reached";
"It's currently not allowed to link more than one device." = "It's currently not allowed to link more than one device.";