mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 21:19:21 +03:00
Cleanup IdentityModel handling
This commit is contained in:
parent
bfffa750ca
commit
d495369688
5 changed files with 17 additions and 27 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import 'External/User/ko';
|
||||
|
||||
import { SMAudio } from 'Common/Audio';
|
||||
import { isArray, pString, pInt } from 'Common/Utils';
|
||||
import { isArray, pInt } from 'Common/Utils';
|
||||
import { mailToHelper, setLayoutResizer, dropdownsDetectVisibility } from 'Common/UtilsUser';
|
||||
|
||||
import {
|
||||
|
|
@ -160,18 +160,7 @@ export class AppUser extends AbstractApp {
|
|||
|
||||
items = oData.Result.Identities;
|
||||
IdentityUserStore(isArray(items)
|
||||
? items.map(identityData => {
|
||||
const identity = new IdentityModel(
|
||||
pString(identityData.Id),
|
||||
pString(identityData.Email)
|
||||
);
|
||||
identity.name(pString(identityData.Name));
|
||||
identity.replyTo(pString(identityData.ReplyTo));
|
||||
identity.bcc(pString(identityData.Bcc));
|
||||
identity.signature(pString(identityData.Signature));
|
||||
identity.signatureInsertBefore(!!identityData.SignatureInsertBefore);
|
||||
return identity;
|
||||
})
|
||||
? items.map(identityData => IdentityModel.reviveFromJson(identityData))
|
||||
: []
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,12 @@ export class IdentityModel extends AbstractModel {
|
|||
* @param {string} id
|
||||
* @param {string} email
|
||||
*/
|
||||
constructor(id, email) {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
addObservablesTo(this, {
|
||||
id: id || '',
|
||||
email: email,
|
||||
id: '',
|
||||
email: '',
|
||||
name: '',
|
||||
|
||||
replyTo: '',
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ export class IdentityPopupView extends AbstractViewPopup {
|
|||
const data = new FormData(form);
|
||||
data.set('Id', this.id);
|
||||
data.set('Signature', this.signature());
|
||||
data.set('SignatureInsertBefore', this.signatureInsertBefore() ? 1 : 0);
|
||||
Remote.request('IdentityUpdate', iError => {
|
||||
this.submitRequest(false);
|
||||
if (iError) {
|
||||
|
|
|
|||
|
|
@ -103,8 +103,7 @@ class Identity implements \JsonSerializable
|
|||
$this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : '';
|
||||
$this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : '';
|
||||
$this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : '';
|
||||
$this->bSignatureInsertBefore = isset($aData['SignatureInsertBefore']) ?
|
||||
!empty($aData['SignatureInsertBefore']) : true;
|
||||
$this->bSignatureInsertBefore = !empty($aData['SignatureInsertBefore']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -112,6 +111,7 @@ class Identity implements \JsonSerializable
|
|||
return false;
|
||||
}
|
||||
|
||||
// Used to store
|
||||
public function ToSimpleJSON(): array
|
||||
{
|
||||
return array(
|
||||
|
|
@ -129,13 +129,14 @@ class Identity implements \JsonSerializable
|
|||
public function jsonSerialize()
|
||||
{
|
||||
return array(
|
||||
'Id' => $this->sId,
|
||||
'Email' => Utils::IdnToUtf8($this->sEmail),
|
||||
'Name' => $this->sName,
|
||||
'ReplyTo' => $this->sReplyTo,
|
||||
'Bcc' => $this->sBcc,
|
||||
'Signature' => $this->sSignature,
|
||||
'SignatureInsertBefore' => $this->bSignatureInsertBefore
|
||||
'@Object' => 'Object/Identity',
|
||||
'id' => $this->sId,
|
||||
'email' => Utils::IdnToUtf8($this->sEmail),
|
||||
'name' => $this->sName,
|
||||
'replyTo' => $this->sReplyTo,
|
||||
'bcc' => $this->sBcc,
|
||||
'signature' => $this->sSignature,
|
||||
'signatureInsertBefore' => $this->bSignatureInsertBefore
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@
|
|||
name: 'Checkbox',
|
||||
params: {
|
||||
label: 'POPUPS_IDENTITY/LABEL_SIGNATURE_INSERT_BEFORE',
|
||||
value: signatureInsertBefore
|
||||
value: signatureInsertBefore,
|
||||
name: 'SignatureInsertBefore'
|
||||
}
|
||||
}"></div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue