mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-10 06:58:27 +03:00
Bugfix: Contacts management failed
It had a strange array type structure and buggy
This commit is contained in:
parent
0e3275599e
commit
3a315bc543
7 changed files with 44 additions and 40 deletions
|
|
@ -31,12 +31,12 @@ class ContactModel extends AbstractModel {
|
|||
if (Array.isNotEmpty(this.properties)) {
|
||||
this.properties.forEach(property => {
|
||||
if (property) {
|
||||
if (ContactPropertyType.FirstName === property[0]) {
|
||||
name = (property[1] + ' ' + name).trim();
|
||||
} else if (ContactPropertyType.LastName === property[0]) {
|
||||
name = (name + ' ' + property[1]).trim();
|
||||
} else if (!email && ContactPropertyType.Email === property[0]) {
|
||||
email = property[1];
|
||||
if (ContactPropertyType.FirstName === property.type()) {
|
||||
name = (property.value() + ' ' + name).trim();
|
||||
} else if (ContactPropertyType.LastName === property.type()) {
|
||||
name = (name + ' ' + property.value()).trim();
|
||||
} else if (!email && ContactPropertyType.Email === property.type()) {
|
||||
email = property.value();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -59,7 +59,7 @@ class ContactModel extends AbstractModel {
|
|||
|
||||
let list = [];
|
||||
if (Array.isNotEmpty(json.properties)) {
|
||||
json.Properties.forEach(property => {
|
||||
json.properties.forEach(property => {
|
||||
property = ContactPropertyModel.reviveFromJson(property);
|
||||
property && list.push(property);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -34,11 +34,19 @@ class ContactPropertyModel extends AbstractModel {
|
|||
this.regDisposables([this.placeholderValue, this.largeValue]);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type(),
|
||||
typeStr: this.typeStr(),
|
||||
value: this.value()
|
||||
};
|
||||
}
|
||||
|
||||
static reviveFromJson(json) {
|
||||
const property = super.reviveFromJson(json);
|
||||
if (property) {
|
||||
property.type(pInt(property.type));
|
||||
property.typeStr(pInt(property.typeStr));
|
||||
property.type(pInt(json.type));
|
||||
property.typeStr(pString(json.typeStr));
|
||||
property.value(pString(json.value));
|
||||
return property;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue