diff --git a/dev/Stores/User/Pgp.js b/dev/Stores/User/Pgp.js index a61dccd3a..ec977b344 100644 --- a/dev/Stores/User/Pgp.js +++ b/dev/Stores/User/Pgp.js @@ -223,6 +223,20 @@ export const PgpUserStore = new class { return !!(window.openpgp || window.mailvelope || Settings.capa(Capa.GnuPG)); } + openpgpImportKey(armoredKey) { + openpgp && openpgp.readKey({armoredKey:armoredKey}).then(key => { + if (!key.err) { + if (key.isPrivate()) { + this.openpgpPrivateKeys.push(new OpenPgpKeyModel(armoredKey, key)); + storeOpenPgpKeys(this.openpgpPrivateKeys, privateKeysItem); + } else { + this.openpgpPublicKeys.push(new OpenPgpKeyModel(armoredKey, key)); + storeOpenPgpKeys(PgpUserStore.openpgpPublicKeys, publicKeysItem); + } + } + }); + } + gnupgImportKey(key, callback) { if (Settings.capa(Capa.GnuPG)) { Remote.request('GnupgImportKey', diff --git a/dev/Styles/User/SettingsOpenPGP.less b/dev/Styles/User/SettingsOpenPGP.less index 87901c72a..9274d6867 100644 --- a/dev/Styles/User/SettingsOpenPGP.less +++ b/dev/Styles/User/SettingsOpenPGP.less @@ -16,4 +16,8 @@ .delete-key:not(:hover) { opacity: 0.7; } + + iframe { + max-width: 991px; + } } diff --git a/dev/View/Popup/OpenPgpImport.js b/dev/View/Popup/OpenPgpImport.js index 79a43ac54..667910208 100644 --- a/dev/View/Popup/OpenPgpImport.js +++ b/dev/View/Popup/OpenPgpImport.js @@ -37,7 +37,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup { this.keyErrorMessage(''); if (!keyTrimmed) { - return false; + return; } let match = null, @@ -54,15 +54,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup { if (this.saveGnuPG()) { PgpUserStore.gnupgImportKey(this.key()); } -/* - if (this.canOpenPGP && this.saveOpenPGP()) { - if ('PRIVATE' === match[1]) { - err = PgpUserStore.openpgpKeyring.privateKeys.importKey(match[0]); - } else if ('PUBLIC' === match[1]) { - err = PgpUserStore.openpgpKeyring.publicKeys.importKey(match[0]); - } - } -*/ + PgpUserStore.openpgpImportKey(this.key()); if (err) { this.keyError(true); this.keyErrorMessage(err && err[0] ? '' + err[0] : ''); @@ -78,11 +70,10 @@ export class OpenPgpImportPopupView extends AbstractViewPopup { } while (!done); if (this.keyError()) { - return false; + return; } this.cancelCommand(); - return true; } onShow() {