Almost all JSON properties to JavaScript camelCase

This commit is contained in:
the-djmaze
2023-01-24 18:58:25 +01:00
parent 7a53cae32f
commit f080a302b1
50 changed files with 501 additions and 562 deletions

View File

@@ -22,7 +22,7 @@ export class AttachmentModel extends AbstractModel {
this.fileNameExt = '';
this.fileType = FileType.Unknown;
this.isThumbnail = false;
this.cid = '';
this.cId = '';
this.contentLocation = '';
this.download = '';
this.folder = '';
@@ -61,7 +61,7 @@ export class AttachmentModel extends AbstractModel {
}
contentId() {
return this.cid.replace(/^<+|>+$/g, '');
return this.cId.replace(/^<+|>+$/g, '');
}
/**

View File

@@ -21,11 +21,11 @@ export class AttachmentCollectionModel extends AbstractCollectionModel
}
/**
* @param {string} cid
* @param {string} cId
* @returns {*}
*/
findByCid(cid) {
cid = cid.replace(/^<+|>+$/g, '');
return this.find(item => cid === item.contentId());
findByCid(cId) {
cId = cId.replace(/^<+|>+$/g, '');
return this.find(item => cId === item.contentId());
}
}

View File

@@ -10,16 +10,16 @@ export class ComposeAttachmentModel extends AbstractModel {
* @param {?number=} size = null
* @param {boolean=} isInline = false
* @param {boolean=} isLinked = false
* @param {string=} CID = ''
* @param {string=} cId = ''
* @param {string=} contentLocation = ''
*/
constructor(id, fileName, size = null, isInline = false, isLinked = false, CID = '', contentLocation = '') {
constructor(id, fileName, size = null, isInline = false, isLinked = false, cId = '', contentLocation = '') {
super();
this.id = id;
this.isInline = !!isInline;
this.isLinked = !!isLinked;
this.CID = CID;
this.cId = cId;
this.contentLocation = contentLocation;
this.fromMessage = false;

View File

@@ -304,7 +304,7 @@ export class ContactModel extends AbstractModel {
// jCard.set('rev', '2022-05-21T10:59:52Z')
return {
Uid: this.id,
uid: this.id,
jCard: JSON.stringify(jCard)
};
}

View File

@@ -124,11 +124,11 @@ export class FolderCollectionModel extends AbstractCollectionModel
);
const result = super.reviveFromJson(object, oFolder => {
let oCacheFolder = getFolderFromCacheList(oFolder.FullName);
let oCacheFolder = getFolderFromCacheList(oFolder.fullName);
if (oCacheFolder) {
// oCacheFolder.revivePropertiesFromJson(oFolder);
if (oFolder.Hash) {
oCacheFolder.hash = oFolder.Hash;
if (oFolder.hash) {
oCacheFolder.hash = oFolder.hash;
}
if (null != oFolder.totalEmails) {
oCacheFolder.totalEmails(oFolder.totalEmails);
@@ -167,32 +167,32 @@ export class FolderCollectionModel extends AbstractCollectionModel
break;
}
// Flags
if (oFolder.Flags.includes('\\sentmail')) {
if (oFolder.flags.includes('\\sentmail')) {
role = 'sent';
}
if (oFolder.Flags.includes('\\spam')) {
if (oFolder.flags.includes('\\spam')) {
role = 'junk';
}
if (oFolder.Flags.includes('\\bin')) {
if (oFolder.flags.includes('\\bin')) {
role = 'trash';
}
if (oFolder.Flags.includes('\\important')) {
if (oFolder.flags.includes('\\important')) {
role = 'important';
}
if (oFolder.Flags.includes('\\starred')) {
if (oFolder.flags.includes('\\starred')) {
role = 'flagged';
}
if (oFolder.Flags.includes('\\all') || oFolder.Flags.includes('\\allmail')) {
if (oFolder.flags.includes('\\all') || oFolder.flags.includes('\\allmail')) {
role = 'all';
}
}
*/
if (role) {
role = role[0].toUpperCase() + role.slice(1);
SystemFolders[role] || (SystemFolders[role] = oFolder.FullName);
SystemFolders[role] || (SystemFolders[role] = oFolder.fullName);
}
oCacheFolder.type(FolderType[getKeyByValue(SystemFolders, oFolder.FullName)] || 0);
oCacheFolder.type(FolderType[getKeyByValue(SystemFolders, oFolder.fullName)] || 0);
oCacheFolder.collapsed(!expandedFolders
|| !isArray(expandedFolders)
@@ -223,12 +223,12 @@ export class FolderCollectionModel extends AbstractCollectionModel
if (!pfolder) {
pfolder = FolderModel.reviveFromJson({
'@Object': 'Object/Folder',
Name: name,
FullName: parentName,
Delimiter: delimiter,
Exists: false,
name: name,
fullName: parentName,
delimiter: delimiter,
exists: false,
isSubscribed: false,
Flags: ['\\nonexistent']
flags: ['\\nonexistent']
});
setFolder(pfolder);
result.splice(i, 0, pfolder);

View File

@@ -43,7 +43,7 @@ const
// MessageFlagsCache.setFor(message.folder, message.uid, flags());
}
}, {
Folder: message.folder,
folder: message.folder,
Uids: message.uid,
Keyword: keyword,
SetAction: isSet ? 0 : 1
@@ -188,12 +188,9 @@ export class MessageModel extends AbstractModel {
* @returns {boolean}
*/
revivePropertiesFromJson(json) {
if ('Priority' in json && ![MessagePriority.High, MessagePriority.Low].includes(json.Priority)) {
json.Priority = MessagePriority.Normal;
}
if (super.revivePropertiesFromJson(json)) {
// this.foundCIDs = isArray(json.FoundCIDs) ? json.FoundCIDs : [];
// this.attachments(AttachmentCollectionModel.reviveFromJson(json.Attachments, this.foundCIDs));
// this.attachments(AttachmentCollectionModel.reviveFromJson(json.attachments, this.foundCIDs));
this.computeSenderEmail();
}

View File

@@ -13,7 +13,7 @@ export class MessageCollectionModel extends AbstractCollectionModel
constructor() {
super();
this.Filtered
this.Folder
this.folder
this.folderHash
this.folderInfo
this.totalEmails