js: simplify getDefaultKey
-- * src/Keyring.js: In case no default Key is set in configuration, only Keys reported as having a secret part should be considered for default Keys, avoiding some extra requests.
This commit is contained in:
parent
622db0d1de
commit
aeb065acc9
@ -192,17 +192,13 @@ export class GPGME_Keyring {
|
|||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// TODO: this is overly 'expensive' in communication
|
let msg = createMessage('keylist');
|
||||||
// and probably performance, too
|
msg.setParameter('secret', true);
|
||||||
me.getKeys(null,true).then(function(keys){
|
msg.post().then(function(result){
|
||||||
for (let i=0; i < keys.length; i++){
|
if (result.keys.length === 0){
|
||||||
if (keys[i].get('hasSecret') === true){
|
|
||||||
resolve(keys[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (i === keys.length -1){
|
|
||||||
reject(gpgme_error('KEY_NO_DEFAULT'));
|
reject(gpgme_error('KEY_NO_DEFAULT'));
|
||||||
}
|
} else {
|
||||||
|
resolve(result.keys[0]);
|
||||||
}
|
}
|
||||||
}, function(error){
|
}, function(error){
|
||||||
reject(error);
|
reject(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user