@@ -77,7 +77,7 @@ View.run(
7777 } else {
7878 let emailText = '' ;
7979 if ( this . parsedPublicKeys . length === 1 ) {
80- const email = this . firstParsedPublicKey . emails [ 0 ] ;
80+ const email = KeyUtil . getPrimaryEmail ( this . firstParsedPublicKey ) ;
8181 if ( email ) {
8282 emailText = email ;
8383 $ ( '.input_email' ) . val ( email ) ; // checked above
@@ -90,7 +90,7 @@ View.run(
9090 Xss . escape (
9191 ' for ' +
9292 this . parsedPublicKeys
93- . map ( pub => pub . emails [ 0 ] )
93+ . map ( pub => KeyUtil . getPrimaryEmail ( pub ) )
9494 . filter ( e => ! ! e )
9595 . join ( ', ' )
9696 )
@@ -193,9 +193,9 @@ View.run(
193193 $ ( '.error_introduce_label' ) . html ( `This OpenPGP key is not usable.<br/><small>(${ await this . getErrorText ( ) } )</small>` ) ; // xss-escaped
194194 $ ( '.hide_if_error' ) . hide ( ) ;
195195 $ ( '.fingerprints, .add_contact, #manual_import_warning' ) . remove ( ) ;
196- const email = this . firstParsedPublicKey ?. emails [ 0 ] ;
196+ const email = this . firstParsedPublicKey ? KeyUtil . getPrimaryEmail ( this . firstParsedPublicKey ) : undefined ;
197197 if ( email ) {
198- $ ( '.error_container .input_error_email' ) . val ( ` ${ this . firstParsedPublicKey ?. emails [ 0 ] } ` ) ;
198+ $ ( '.error_container .input_error_email' ) . val ( email ) ;
199199 } else {
200200 $ ( '.error_container .input_error_email' ) . hide ( ) ;
201201 }
@@ -208,7 +208,7 @@ View.run(
208208 const emails = new Set < string > ( ) ;
209209 for ( const pubkey of this . parsedPublicKeys ! ) {
210210 /* eslint-enable @typescript-eslint/no-non-null-assertion */
211- const email = pubkey . emails [ 0 ] ;
211+ const email = KeyUtil . getPrimaryEmail ( pubkey ) ;
212212 if ( email ) {
213213 await ContactStore . update ( undefined , email , { pubkey : KeyUtil . armor ( pubkey ) } ) ;
214214 emails . add ( email ) ;
0 commit comments