mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Cleanup OpenPgpImportPopupView code
This commit is contained in:
parent
0efc0bbe3a
commit
f94fc34d4f
1 changed files with 21 additions and 27 deletions
|
|
@ -78,22 +78,19 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
|
||||||
this.keyError(!keyTrimmed);
|
this.keyError(!keyTrimmed);
|
||||||
this.keyErrorMessage('');
|
this.keyErrorMessage('');
|
||||||
|
|
||||||
if (!keyTrimmed) {
|
if (keyTrimmed) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let match = null,
|
let match = null,
|
||||||
count = 30,
|
count = 30,
|
||||||
done = false;
|
done = false;
|
||||||
|
const GnuPG = this.saveGnuPG() && GnuPGUserStore.isSupported(),
|
||||||
|
backup = this.saveServer(),
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
const reg = /[-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}[\s\S]+?[-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}/gi;
|
reg = /[-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}[\s\S]+?[-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[-]{3,6}/gi;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
match = reg.exec(keyTrimmed);
|
match = reg.exec(keyTrimmed);
|
||||||
if (match && 0 < count) {
|
if (match && 0 < count) {
|
||||||
if (match[0] && match[1] && match[2] && match[1] === match[2]) {
|
if (match[0] && match[1] && match[2] && match[1] === match[2]) {
|
||||||
const GnuPG = this.saveGnuPG() && GnuPGUserStore.isSupported(),
|
|
||||||
backup = this.saveServer();
|
|
||||||
PgpUserStore.importKey(this.key(), GnuPG, backup);
|
PgpUserStore.importKey(this.key(), GnuPG, backup);
|
||||||
}
|
}
|
||||||
--count;
|
--count;
|
||||||
|
|
@ -103,12 +100,9 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
} while (!done);
|
} while (!done);
|
||||||
|
|
||||||
if (this.keyError()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onShow(key) {
|
onShow(key) {
|
||||||
this.key(key || '');
|
this.key(key || '');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue