mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 04:59:21 +03:00
Use JavaScript Optional chaining
This commit is contained in:
parent
d9bc435e2c
commit
732b6eb641
55 changed files with 169 additions and 199 deletions
|
|
@ -12,7 +12,7 @@ export class AbstractCollectionModel extends Array
|
|||
}
|
||||
|
||||
onDestroy() {
|
||||
this.forEach(item => item.onDestroy && item.onDestroy());
|
||||
this.forEach(item => item.onDestroy?.());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ export class EmailModel extends AbstractModel {
|
|||
*/
|
||||
static reviveFromJson(json) {
|
||||
const email = super.reviveFromJson(json);
|
||||
email && email.clearDuplicateName();
|
||||
email?.clearDuplicateName();
|
||||
return email;
|
||||
}
|
||||
|
||||
|
|
@ -351,7 +351,7 @@ export class EmailModel extends AbstractModel {
|
|||
? new EmailModel(item.address.replace(/^[<]+(.*)[>]+$/g, '$1'), item.name || '')
|
||||
: null;
|
||||
|
||||
if (address && address.email) {
|
||||
if (address?.email) {
|
||||
exists = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export class EmailCollectionModel extends AbstractCollectionModel
|
|||
toStringClear() {
|
||||
const result = [];
|
||||
this.forEach(email => {
|
||||
if (email && email.email && email.name) {
|
||||
if (email?.email && email?.name) {
|
||||
result.push(email.email);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ export const
|
|||
.post('Folders', FolderUserStore.foldersLoading)
|
||||
.then(data => {
|
||||
data = FolderCollectionModel.reviveFromJson(data.Result);
|
||||
data && data.storeIt();
|
||||
fCallback && fCallback(true);
|
||||
data?.storeIt();
|
||||
fCallback?.(true);
|
||||
// Repeat every 15 minutes?
|
||||
// this.foldersTimeout = setTimeout(loadFolders, 900000);
|
||||
})
|
||||
|
|
@ -128,7 +128,7 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
|||
*/
|
||||
static reviveFromJson(object) {
|
||||
const expandedFolders = Local.get(ClientSideKeyNameExpandedFolders);
|
||||
if (object && object.SystemFolders) {
|
||||
if (object?.SystemFolders) {
|
||||
forEachObjectEntry(SystemFolders, key =>
|
||||
SystemFolders[key] = SettingsGet(key+'Folder') || object.SystemFolders[FolderType[key]]
|
||||
);
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ export class MessageModel extends AbstractModel {
|
|||
*/
|
||||
fromDkimData() {
|
||||
let result = ['none', ''];
|
||||
if (1 === arrayLength(this.from) && this.from[0] && this.from[0].dkimStatus) {
|
||||
if (1 === arrayLength(this.from) && this.from[0]?.dkimStatus) {
|
||||
result = [this.from[0].dkimStatus, this.from[0].dkimValue || ''];
|
||||
}
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ export class MessageModel extends AbstractModel {
|
|||
* @returns {string}
|
||||
*/
|
||||
fromAsSingleEmail() {
|
||||
return isArray(this.from) && this.from[0] ? this.from[0].email : '';
|
||||
return (isArray(this.from) && this.from[0]?.email) || '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue