@@ -49,6 +49,13 @@ const LINK_DEVICE_EMAIL_ADDRESS = remoteData.recipientId
4949 : `${ remoteData . recipientId } @${ appDomain } `
5050 : '' ;
5151
52+ const getRecipientIdFromRemoteData = ( ) => {
53+ const { recipientId } = remoteData ;
54+ return recipientId . includes ( `@${ appDomain } ` )
55+ ? recipientId . split ( '@' ) [ 0 ]
56+ : recipientId ;
57+ } ;
58+
5259class LoadingWrapper extends Component {
5360 constructor ( props ) {
5461 super ( props ) ;
@@ -71,10 +78,10 @@ class LoadingWrapper extends Component {
7178 this . setState ( { message : messages . sendingKeys , pauseAt : 10 } , async ( ) => {
7279 this . incrementPercentage ( ) ;
7380 await setTimeout ( async ( ) => {
74- const { name, recipientId , deviceType } = remoteData ;
81+ const { name, deviceType } = remoteData ;
7582 await this . generateAccountAndKeys ( {
7683 deviceType,
77- recipientId,
84+ recipientId : getRecipientIdFromRemoteData ( ) ,
7885 deviceId : 0 ,
7986 name
8087 } ) ;
@@ -126,6 +133,7 @@ class LoadingWrapper extends Component {
126133 async ( ) => {
127134 try {
128135 this . incrementPercentage ( ) ;
136+ await cleanKeys ( ) ;
129137 const keybundle = await signal . generateAccountAndKeys ( params ) ;
130138 if ( ! keybundle ) {
131139 await cleanKeys ( ) ;
@@ -157,18 +165,11 @@ class LoadingWrapper extends Component {
157165 this . linkingDevicesThrowError ( ) ;
158166 return ;
159167 }
160- let isRecipientApp = false ;
161- let username = remoteData . recipientId ;
162- if ( remoteData . recipientId . includes ( `@${ appDomain } ` ) ) {
163- isRecipientApp = true ;
164- [ username ] = remoteData . recipientId . split ( '@' ) ;
165- }
166168 const newAccountData = {
167169 ...remoteData ,
168170 ...accountData ,
169- recipientId : username ,
170- deviceId : remoteData . deviceId ,
171- isRecipientApp
171+ recipientId : getRecipientIdFromRemoteData ( ) ,
172+ deviceId : remoteData . deviceId
172173 } ;
173174 await signal . createAccountToDB ( newAccountData ) ;
174175 this . setState (
@@ -274,11 +275,10 @@ class LoadingWrapper extends Component {
274275 async ( ) => {
275276 this . incrementPercentage ( ) ;
276277 const MESSAGE_PRE_KEY = 3 ;
277- const { recipientId } = remoteData ;
278278 try {
279279 const decryptedKey = await signal . decryptKey ( {
280280 text : key ,
281- recipientId,
281+ recipientId : getRecipientIdFromRemoteData ( ) ,
282282 deviceId : authorizerId ,
283283 messageType : MESSAGE_PRE_KEY
284284 } ) ;
0 commit comments