@ -156,37 +156,14 @@ final class LandingVC : UIViewController, LinkDeviceVCDelegate, DeviceLinkingMod
databaseConnection . setObject ( keyPair , forKey : OWSPrimaryStorageIdentityKeyStoreIdentityKey , inCollection : OWSPrimaryStorageIdentityKeyStoreCollection )
TSAccountManager . sharedInstance ( ) . phoneNumberAwaitingVerification = keyPair . hexEncodedPublicKey
TSAccountManager . sharedInstance ( ) . didRegister ( )
setUserInteractionEnabled ( false )
let _ = LokiFileServerAPI . getDeviceLinks ( associatedWith : hexEncodedPublicKey ) . done ( on : DispatchQueue . main ) { [ weak self ] deviceLinks in
guard let self = self else { return }
defer { self . setUserInteractionEnabled ( true ) }
guard deviceLinks . count < 2 else {
let alert = UIAlertController ( title : " Multi Device Limit Reached " , message : " It's currently not allowed to link more than one device. " , preferredStyle : . alert )
alert . addAction ( UIAlertAction ( title : " OK " , accessibilityIdentifier : nil , style : . default , handler : nil ) )
return self . present ( alert , animated : true , completion : nil )
}
let appDelegate = UIApplication . shared . delegate as ! AppDelegate
appDelegate . startLongPollerIfNeeded ( )
let deviceLinkingModal = DeviceLinkingModal ( mode : . slave , delegate : self )
deviceLinkingModal . modalPresentationStyle = . overFullScreen
deviceLinkingModal . modalTransitionStyle = . crossDissolve
self . present ( deviceLinkingModal , animated : true , completion : nil )
let linkingRequestMessage = DeviceLinkingUtilities . getLinkingRequestMessage ( for : hexEncodedPublicKey )
ThreadUtil . enqueue ( linkingRequestMessage )
} . catch ( on : DispatchQueue . main ) { [ weak self ] _ in
let appDelegate = UIApplication . shared . delegate as ! AppDelegate
appDelegate . stopLongPollerIfNeeded ( )
DispatchQueue . main . async {
// FIXME: F o r s o m e r e a s o n r e s e t F o r R e g i s t r a t i o n ( ) c o m p l a i n s a b o u t n o t b e i n g o n t h e m a i n q u e u e
// w i t h o u t t h i s ( e v e n t h o u g h t h e c a t c h c l o s u r e s h o u l d b e e x e c u t e d o n t h e m a i n q u e u e )
TSAccountManager . sharedInstance ( ) . resetForReregistration ( )
}
guard let self = self else { return }
let alert = UIAlertController ( title : NSLocalizedString ( " Couldn't Link Device " , comment : " " ) , message : NSLocalizedString ( " Please check your internet connection and try again " , comment : " " ) , preferredStyle : . alert )
alert . addAction ( UIAlertAction ( title : " OK " , accessibilityIdentifier : nil , style : . default , handler : nil ) )
self . present ( alert , animated : true , completion : nil )
self . setUserInteractionEnabled ( true )
}
let appDelegate = UIApplication . shared . delegate as ! AppDelegate
appDelegate . startLongPollerIfNeeded ( )
let deviceLinkingModal = DeviceLinkingModal ( mode : . slave , delegate : self )
deviceLinkingModal . modalPresentationStyle = . overFullScreen
deviceLinkingModal . modalTransitionStyle = . crossDissolve
self . present ( deviceLinkingModal , animated : true , completion : nil )
let linkingRequestMessage = DeviceLinkingUtilities . getLinkingRequestMessage ( for : hexEncodedPublicKey )
ThreadUtil . enqueue ( linkingRequestMessage )
}
func handleDeviceLinkAuthorized ( _ deviceLink : DeviceLink ) {