Added options to Identity for PGP sign and encrypt #89

This commit is contained in:
the-djmaze 2024-02-11 21:16:38 +01:00
parent 4c84c6cdfc
commit c72c2dbaa4
6 changed files with 65 additions and 46 deletions

View file

@ -21,6 +21,9 @@ export class IdentityModel extends AbstractModel {
signature: '',
signatureInsertBefore: false,
pgpSign: false,
pgpEncrypt: false,
askDelete: false
});
}

View file

@ -346,7 +346,13 @@ export class ComposePopupView extends AbstractViewPopup {
sendSuccessButSaveError: value => !value && this.savedErrorDesc(''),
currentIdentity: value => value && this.from(value.formattedName()),
currentIdentity: value => {
if (value) {
this.from(value.formattedName());
this.pgpEncrypt(value.pgpEncrypt/* || SettingsUserStore.pgpEncrypt()*/);
this.pgpSign(value.pgpSign/* || SettingsUserStore.pgpSign()*/);
}
},
from: value => {
this.canPgpSign(false);
@ -1389,14 +1395,6 @@ export class ComposePopupView extends AbstractViewPopup {
});
}
togglePgpSign() {
this.pgpSign(!this.pgpSign()/* && this.canPgpSign()*/);
}
togglePgpEncrypt() {
this.pgpEncrypt(!this.pgpEncrypt()/* && this.canPgpEncrypt()*/);
}
async getMessageRequestParams(sSaveFolder, draft)
{
let Text = this.oEditor.getData().trim(),

View file

@ -15,22 +15,10 @@ export class IdentityPopupView extends AbstractViewPopup {
super('Identity');
addObservablesTo(this, {
id: '',
identity: null,
edit: false,
label: '',
labelFocused: false,
email: '',
name: '',
nameFocused: false,
replyTo: '',
bcc: '',
signature: '',
signatureInsertBefore: false,
submitRequest: false,
submitError: ''
});
@ -43,11 +31,12 @@ export class IdentityPopupView extends AbstractViewPopup {
submitForm(form) {
if (!this.submitRequest() && form.reportValidity()) {
this.signature?.__fetchEditorValue?.();
let identity = this.identity();
identity.signature?.__fetchEditorValue?.();
this.submitRequest(true);
const data = new FormData(form);
data.set('Id', this.id());
data.set('Signature', this.signature());
data.set('Id', identity.id());
data.set('Signature', identity.signature());
Remote.request('IdentityUpdate', iError => {
this.submitRequest(false);
if (iError) {
@ -67,7 +56,6 @@ export class IdentityPopupView extends AbstractViewPopup {
onShow(identity) {
this.submitRequest(false);
this.submitError('');
if (identity) {
this.edit(true);
} else {
@ -75,17 +63,10 @@ export class IdentityPopupView extends AbstractViewPopup {
identity = new IdentityModel;
identity.id(Jua.randomId());
}
this.id(identity.id() || '');
this.label(identity.label() || '');
this.name(identity.name());
this.email(identity.email());
this.replyTo(identity.replyTo());
this.bcc(identity.bcc());
this.signature(identity.signature());
this.signatureInsertBefore(identity.signatureInsertBefore());
this.identity(identity);
}
afterShow() {
this.id() ? this.labelFocused(true) : this.nameFocused(true);
this.identity().id() ? this.labelFocused(true) : this.nameFocused(true);
}
}