mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,19 +1,16 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {change} from 'Common/Links';
|
||||
import { change } from 'Common/Links';
|
||||
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class AccountModel extends AbstractModel
|
||||
{
|
||||
class AccountModel extends AbstractModel {
|
||||
/**
|
||||
* @param {string} email
|
||||
* @param {boolean=} canBeDelete = true
|
||||
* @param {number=} count = 0
|
||||
*/
|
||||
constructor(email, canBeDelete = true, count = 0)
|
||||
{
|
||||
constructor(email, canBeDelete = true, count = 0) {
|
||||
super('AccountModel');
|
||||
|
||||
this.email = email;
|
||||
|
|
@ -33,4 +30,4 @@ class AccountModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {AccountModel, AccountModel as default};
|
||||
export { AccountModel, AccountModel as default };
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {FileType} from 'Common/Enums';
|
||||
import {bAllowPdfPreview, data as GlobalsData} from 'Common/Globals';
|
||||
import {trim, pInt, inArray, isNonEmptyArray, getFileExtension, friendlySize} from 'Common/Utils';
|
||||
import {attachmentDownload, attachmentPreview, attachmentFramed, attachmentPreviewAsPlain, attachmentThumbnailPreview} from 'Common/Links';
|
||||
import { FileType } from 'Common/Enums';
|
||||
import { bAllowPdfPreview, data as GlobalsData } from 'Common/Globals';
|
||||
import { trim, pInt, inArray, isNonEmptyArray, getFileExtension, friendlySize } from 'Common/Utils';
|
||||
import {
|
||||
attachmentDownload,
|
||||
attachmentPreview,
|
||||
attachmentFramed,
|
||||
attachmentPreviewAsPlain,
|
||||
attachmentThumbnailPreview
|
||||
} from 'Common/Links';
|
||||
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
import Audio from 'Common/Audio';
|
||||
|
||||
|
|
@ -24,90 +29,99 @@ export const staticFileType = _.memoize((ext, mimeType) => {
|
|||
let result = FileType.Unknown;
|
||||
const mimeTypeParts = mimeType.split('/');
|
||||
|
||||
switch (true)
|
||||
{
|
||||
case 'image' === mimeTypeParts[0] || -1 < inArray(ext, [
|
||||
'png', 'jpg', 'jpeg', 'gif', 'bmp'
|
||||
]):
|
||||
switch (true) {
|
||||
case 'image' === mimeTypeParts[0] || -1 < inArray(ext, ['png', 'jpg', 'jpeg', 'gif', 'bmp']):
|
||||
result = FileType.Image;
|
||||
break;
|
||||
case 'audio' === mimeTypeParts[0] || -1 < inArray(ext, [
|
||||
'mp3', 'ogg', 'oga', 'wav'
|
||||
]):
|
||||
case 'audio' === mimeTypeParts[0] || -1 < inArray(ext, ['mp3', 'ogg', 'oga', 'wav']):
|
||||
result = FileType.Audio;
|
||||
break;
|
||||
case 'video' === mimeTypeParts[0] || -1 < inArray(ext, [
|
||||
'mkv', 'avi'
|
||||
]):
|
||||
case 'video' === mimeTypeParts[0] || -1 < inArray(ext, ['mkv', 'avi']):
|
||||
result = FileType.Video;
|
||||
break;
|
||||
case -1 < inArray(ext, [
|
||||
'php', 'js', 'css'
|
||||
]):
|
||||
case -1 < inArray(ext, ['php', 'js', 'css']):
|
||||
result = FileType.Code;
|
||||
break;
|
||||
case 'eml' === ext || -1 < inArray(mimeType, [
|
||||
'message/delivery-status', 'message/rfc822'
|
||||
]):
|
||||
case 'eml' === ext || -1 < inArray(mimeType, ['message/delivery-status', 'message/rfc822']):
|
||||
result = FileType.Eml;
|
||||
break;
|
||||
case ('text' === mimeTypeParts[0] && 'html' !== mimeTypeParts[1]) || -1 < inArray(ext, [
|
||||
'txt', 'log'
|
||||
]):
|
||||
case ('text' === mimeTypeParts[0] && 'html' !== mimeTypeParts[1]) || -1 < inArray(ext, ['txt', 'log']):
|
||||
result = FileType.Text;
|
||||
break;
|
||||
case ('text/html' === mimeType) || -1 < inArray(ext, [
|
||||
'html'
|
||||
]):
|
||||
case 'text/html' === mimeType || -1 < inArray(ext, ['html']):
|
||||
result = FileType.Html;
|
||||
break;
|
||||
case -1 < inArray(mimeTypeParts[1], [
|
||||
'zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2', 'x-zip', 'x-7z', 'x-rar', 'x-tar', 'x-gzip', 'x-bzip', 'x-bzip2', 'x-zip-compressed', 'x-7z-compressed', 'x-rar-compressed'
|
||||
]) || -1 < inArray(ext, ['zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2']):
|
||||
case -1 <
|
||||
inArray(mimeTypeParts[1], [
|
||||
'zip',
|
||||
'7z',
|
||||
'tar',
|
||||
'rar',
|
||||
'gzip',
|
||||
'bzip',
|
||||
'bzip2',
|
||||
'x-zip',
|
||||
'x-7z',
|
||||
'x-rar',
|
||||
'x-tar',
|
||||
'x-gzip',
|
||||
'x-bzip',
|
||||
'x-bzip2',
|
||||
'x-zip-compressed',
|
||||
'x-7z-compressed',
|
||||
'x-rar-compressed'
|
||||
]) || -1 < inArray(ext, ['zip', '7z', 'tar', 'rar', 'gzip', 'bzip', 'bzip2']):
|
||||
result = FileType.Archive;
|
||||
break;
|
||||
case -1 < inArray(mimeTypeParts[1], ['pdf', 'x-pdf']) || -1 < inArray(ext, ['pdf']):
|
||||
result = FileType.Pdf;
|
||||
break;
|
||||
case -1 < inArray(mimeType, [
|
||||
'application/pgp-signature', 'application/pgp-keys'
|
||||
]) || -1 < inArray(ext, ['asc', 'pem', 'ppk']):
|
||||
case -1 < inArray(mimeType, ['application/pgp-signature', 'application/pgp-keys']) ||
|
||||
-1 < inArray(ext, ['asc', 'pem', 'ppk']):
|
||||
result = FileType.Certificate;
|
||||
break;
|
||||
case -1 < inArray(mimeType, ['application/pkcs7-signature']) ||
|
||||
-1 < inArray(ext, ['p7s']):
|
||||
|
||||
case -1 < inArray(mimeType, ['application/pkcs7-signature']) || -1 < inArray(ext, ['p7s']):
|
||||
result = FileType.CertificateBin;
|
||||
break;
|
||||
case -1 < inArray(mimeTypeParts[1], [
|
||||
'rtf', 'msword', 'vnd.msword', 'vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'vnd.ms-word.document.macroEnabled.12',
|
||||
'vnd.ms-word.template.macroEnabled.12'
|
||||
]):
|
||||
case -1 <
|
||||
inArray(mimeTypeParts[1], [
|
||||
'rtf',
|
||||
'msword',
|
||||
'vnd.msword',
|
||||
'vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'vnd.ms-word.document.macroEnabled.12',
|
||||
'vnd.ms-word.template.macroEnabled.12'
|
||||
]):
|
||||
result = FileType.WordText;
|
||||
break;
|
||||
case -1 < inArray(mimeTypeParts[1], [
|
||||
'excel', 'ms-excel', 'vnd.ms-excel',
|
||||
'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
'vnd.ms-excel.sheet.macroEnabled.12',
|
||||
'vnd.ms-excel.template.macroEnabled.12',
|
||||
'vnd.ms-excel.addin.macroEnabled.12',
|
||||
'vnd.ms-excel.sheet.binary.macroEnabled.12'
|
||||
]):
|
||||
case -1 <
|
||||
inArray(mimeTypeParts[1], [
|
||||
'excel',
|
||||
'ms-excel',
|
||||
'vnd.ms-excel',
|
||||
'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
'vnd.ms-excel.sheet.macroEnabled.12',
|
||||
'vnd.ms-excel.template.macroEnabled.12',
|
||||
'vnd.ms-excel.addin.macroEnabled.12',
|
||||
'vnd.ms-excel.sheet.binary.macroEnabled.12'
|
||||
]):
|
||||
result = FileType.Sheet;
|
||||
break;
|
||||
case -1 < inArray(mimeTypeParts[1], [
|
||||
'powerpoint', 'ms-powerpoint', 'vnd.ms-powerpoint',
|
||||
'vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'vnd.openxmlformats-officedocument.presentationml.template',
|
||||
'vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||
'vnd.ms-powerpoint.addin.macroEnabled.12',
|
||||
'vnd.ms-powerpoint.presentation.macroEnabled.12',
|
||||
'vnd.ms-powerpoint.template.macroEnabled.12',
|
||||
'vnd.ms-powerpoint.slideshow.macroEnabled.12'
|
||||
]):
|
||||
case -1 <
|
||||
inArray(mimeTypeParts[1], [
|
||||
'powerpoint',
|
||||
'ms-powerpoint',
|
||||
'vnd.ms-powerpoint',
|
||||
'vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'vnd.openxmlformats-officedocument.presentationml.template',
|
||||
'vnd.openxmlformats-officedocument.presentationml.slideshow',
|
||||
'vnd.ms-powerpoint.addin.macroEnabled.12',
|
||||
'vnd.ms-powerpoint.presentation.macroEnabled.12',
|
||||
'vnd.ms-powerpoint.template.macroEnabled.12',
|
||||
'vnd.ms-powerpoint.slideshow.macroEnabled.12'
|
||||
]):
|
||||
result = FileType.Presentation;
|
||||
break;
|
||||
// no default
|
||||
|
|
@ -121,12 +135,10 @@ export const staticFileType = _.memoize((ext, mimeType) => {
|
|||
* @returns {string}
|
||||
*/
|
||||
export const staticIconClass = _.memoize((fileType) => {
|
||||
let
|
||||
resultText = '',
|
||||
let resultText = '',
|
||||
resultClass = 'icon-file';
|
||||
|
||||
switch (fileType)
|
||||
{
|
||||
switch (fileType) {
|
||||
case FileType.Text:
|
||||
case FileType.Eml:
|
||||
case FileType.WordText:
|
||||
|
|
@ -174,19 +186,15 @@ export const staticIconClass = _.memoize((fileType) => {
|
|||
* @returns {string}
|
||||
*/
|
||||
export const staticCombinedIconClass = (data) => {
|
||||
let
|
||||
result = '',
|
||||
let result = '',
|
||||
types = [];
|
||||
|
||||
if (isNonEmptyArray(data))
|
||||
{
|
||||
if (isNonEmptyArray(data)) {
|
||||
result = 'icon-attachment';
|
||||
types = _.uniq(_.compact(_.map(data, (item) => (item ? staticFileType(getFileExtension(item[0]), item[1]) : ''))));
|
||||
|
||||
if (types && 1 === types.length && types[0])
|
||||
{
|
||||
switch (types[0])
|
||||
{
|
||||
if (types && 1 === types.length && types[0]) {
|
||||
switch (types[0]) {
|
||||
case FileType.Text:
|
||||
case FileType.WordText:
|
||||
result = 'icon-file-text';
|
||||
|
|
@ -225,8 +233,7 @@ export const staticCombinedIconClass = (data) => {
|
|||
return result;
|
||||
};
|
||||
|
||||
class AttachmentModel extends AbstractModel
|
||||
{
|
||||
class AttachmentModel extends AbstractModel {
|
||||
constructor() {
|
||||
super('AttachmentModel');
|
||||
|
||||
|
|
@ -267,8 +274,7 @@ class AttachmentModel extends AbstractModel
|
|||
*/
|
||||
initByJson(json) {
|
||||
let bResult = false;
|
||||
if (json && 'Object/Attachment' === json['@Object'])
|
||||
{
|
||||
if (json && 'Object/Attachment' === json['@Object']) {
|
||||
this.mimeType = trim((json.MimeType || '').toLowerCase());
|
||||
this.fileName = trim(json.FileName);
|
||||
this.estimatedSize = pInt(json.EstimatedSize);
|
||||
|
|
@ -335,8 +341,13 @@ class AttachmentModel extends AbstractModel
|
|||
* @returns {boolean}
|
||||
*/
|
||||
isText() {
|
||||
return FileType.Text === this.fileType || FileType.Eml === this.fileType ||
|
||||
FileType.Certificate === this.fileType || FileType.Html === this.fileType || FileType.Code === this.fileType;
|
||||
return (
|
||||
FileType.Text === this.fileType ||
|
||||
FileType.Eml === this.fileType ||
|
||||
FileType.Certificate === this.fileType ||
|
||||
FileType.Html === this.fileType ||
|
||||
FileType.Code === this.fileType
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -350,8 +361,13 @@ class AttachmentModel extends AbstractModel
|
|||
* @returns {boolean}
|
||||
*/
|
||||
isFramed() {
|
||||
return this.framed && (GlobalsData.__APP__ && GlobalsData.__APP__.googlePreviewSupported()) &&
|
||||
!(this.isPdf() && bAllowPdfPreview) && !this.isText() && !this.isImage();
|
||||
return (
|
||||
this.framed &&
|
||||
(GlobalsData.__APP__ && GlobalsData.__APP__.googlePreviewSupported()) &&
|
||||
!(this.isPdf() && bAllowPdfPreview) &&
|
||||
!this.isText() &&
|
||||
!this.isImage()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -365,7 +381,11 @@ class AttachmentModel extends AbstractModel
|
|||
* @returns {boolean}
|
||||
*/
|
||||
hasPreplay() {
|
||||
return (Audio.supportedMp3 && this.isMp3()) || (Audio.supportedOgg && this.isOgg()) || (Audio.supportedWav && this.isWav());
|
||||
return (
|
||||
(Audio.supportedMp3 && this.isMp3()) ||
|
||||
(Audio.supportedOgg && this.isOgg()) ||
|
||||
(Audio.supportedWav && this.isWav())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -416,8 +436,7 @@ class AttachmentModel extends AbstractModel
|
|||
*/
|
||||
linkPreviewMain() {
|
||||
let result = '';
|
||||
switch (true)
|
||||
{
|
||||
switch (true) {
|
||||
case this.isImage():
|
||||
case this.isPdf() && bAllowPdfPreview:
|
||||
result = this.linkPreview();
|
||||
|
|
@ -439,8 +458,7 @@ class AttachmentModel extends AbstractModel
|
|||
*/
|
||||
generateTransferDownloadUrl() {
|
||||
let link = this.linkDownload();
|
||||
if ('http' !== link.substr(0, 4))
|
||||
{
|
||||
if ('http' !== link.substr(0, 4)) {
|
||||
link = window.location.protocol + '//' + window.location.host + window.location.pathname + link;
|
||||
}
|
||||
|
||||
|
|
@ -454,8 +472,7 @@ class AttachmentModel extends AbstractModel
|
|||
*/
|
||||
eventDragStart(attachment, event) {
|
||||
const localEvent = event.originalEvent || event;
|
||||
if (attachment && localEvent && localEvent.dataTransfer && localEvent.dataTransfer.setData)
|
||||
{
|
||||
if (attachment && localEvent && localEvent.dataTransfer && localEvent.dataTransfer.setData) {
|
||||
localEvent.dataTransfer.setData('DownloadURL', this.generateTransferDownloadUrl());
|
||||
}
|
||||
|
||||
|
|
@ -477,4 +494,4 @@ class AttachmentModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {AttachmentModel, AttachmentModel as default};
|
||||
export { AttachmentModel, AttachmentModel as default };
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
|
||||
import ko from 'ko';
|
||||
import {isUnd, pInt, friendlySize, mimeContentType, getFileExtension} from 'Common/Utils';
|
||||
import { isUnd, pInt, friendlySize, mimeContentType, getFileExtension } from 'Common/Utils';
|
||||
|
||||
import {staticIconClass, staticFileType} from 'Model/Attachment';
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { staticIconClass, staticFileType } from 'Model/Attachment';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class ComposeAttachmentModel extends AbstractModel
|
||||
{
|
||||
class ComposeAttachmentModel extends AbstractModel {
|
||||
/**
|
||||
* @param {string} id
|
||||
* @param {string} fileName
|
||||
|
|
@ -16,8 +14,7 @@ class ComposeAttachmentModel extends AbstractModel
|
|||
* @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('ComposeAttachmentModel');
|
||||
|
||||
this.id = id;
|
||||
|
|
@ -61,7 +58,14 @@ class ComposeAttachmentModel extends AbstractModel
|
|||
this.mimeType = ko.computed(() => mimeContentType(this.fileName()));
|
||||
this.fileExt = ko.computed(() => getFileExtension(this.fileName()));
|
||||
|
||||
this.regDisposables([this.progressText, this.progressStyle, this.title, this.friendlySize, this.mimeType, this.fileExt]);
|
||||
this.regDisposables([
|
||||
this.progressText,
|
||||
this.progressStyle,
|
||||
this.title,
|
||||
this.friendlySize,
|
||||
this.mimeType,
|
||||
this.fileExt
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,8 +74,7 @@ class ComposeAttachmentModel extends AbstractModel
|
|||
*/
|
||||
initByUploadJson(json) {
|
||||
let bResult = false;
|
||||
if (json)
|
||||
{
|
||||
if (json) {
|
||||
this.fileName(json.Name);
|
||||
this.size(isUnd(json.Size) ? 0 : pInt(json.Size));
|
||||
this.tempName(isUnd(json.TempName) ? '' : json.TempName);
|
||||
|
|
@ -98,4 +101,4 @@ class ComposeAttachmentModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {ComposeAttachmentModel, ComposeAttachmentModel as default};
|
||||
export { ComposeAttachmentModel, ComposeAttachmentModel as default };
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {ContactPropertyType} from 'Common/Enums';
|
||||
import {trim, isNonEmptyArray, isNormal, pInt, pString} from 'Common/Utils';
|
||||
import {emptyContactPic} from 'Common/Links';
|
||||
import { ContactPropertyType } from 'Common/Enums';
|
||||
import { trim, isNonEmptyArray, isNormal, pInt, pString } from 'Common/Utils';
|
||||
import { emptyContactPic } from 'Common/Links';
|
||||
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class ContactModel extends AbstractModel
|
||||
{
|
||||
class ContactModel extends AbstractModel {
|
||||
constructor() {
|
||||
super('ContactModel');
|
||||
|
||||
|
|
@ -28,25 +26,17 @@ class ContactModel extends AbstractModel
|
|||
* @returns {Array|null}
|
||||
*/
|
||||
getNameAndEmailHelper() {
|
||||
let
|
||||
name = '',
|
||||
let name = '',
|
||||
email = '';
|
||||
|
||||
if (isNonEmptyArray(this.properties))
|
||||
{
|
||||
if (isNonEmptyArray(this.properties)) {
|
||||
_.each(this.properties, (property) => {
|
||||
if (property)
|
||||
{
|
||||
if (ContactPropertyType.FirstName === property[0])
|
||||
{
|
||||
if (property) {
|
||||
if (ContactPropertyType.FirstName === property[0]) {
|
||||
name = trim(property[1] + ' ' + name);
|
||||
}
|
||||
else if (ContactPropertyType.LastName === property[0])
|
||||
{
|
||||
} else if (ContactPropertyType.LastName === property[0]) {
|
||||
name = trim(name + ' ' + property[1]);
|
||||
}
|
||||
else if ('' === email && ContactPropertyType.Email === property[0])
|
||||
{
|
||||
} else if ('' === email && ContactPropertyType.Email === property[0]) {
|
||||
email = property[1];
|
||||
}
|
||||
}
|
||||
|
|
@ -62,17 +52,14 @@ class ContactModel extends AbstractModel
|
|||
*/
|
||||
parse(json) {
|
||||
let result = false;
|
||||
if (json && 'Object/Contact' === json['@Object'])
|
||||
{
|
||||
if (json && 'Object/Contact' === json['@Object']) {
|
||||
this.idContact = pInt(json.IdContact);
|
||||
this.display = pString(json.Display);
|
||||
this.readOnly = !!json.ReadOnly;
|
||||
|
||||
if (isNonEmptyArray(json.Properties))
|
||||
{
|
||||
if (isNonEmptyArray(json.Properties)) {
|
||||
_.each(json.Properties, (property) => {
|
||||
if (property && property.Type && isNormal(property.Value) && isNormal(property.TypeStr))
|
||||
{
|
||||
if (property && property.Type && isNormal(property.Value) && isNormal(property.TypeStr)) {
|
||||
this.properties.push([pInt(property.Type), pString(property.Value), pString(property.TypeStr)]);
|
||||
}
|
||||
});
|
||||
|
|
@ -103,20 +90,16 @@ class ContactModel extends AbstractModel
|
|||
*/
|
||||
lineAsCss() {
|
||||
const result = [];
|
||||
if (this.deleted())
|
||||
{
|
||||
if (this.deleted()) {
|
||||
result.push('deleted');
|
||||
}
|
||||
if (this.selected())
|
||||
{
|
||||
if (this.selected()) {
|
||||
result.push('selected');
|
||||
}
|
||||
if (this.checked())
|
||||
{
|
||||
if (this.checked()) {
|
||||
result.push('checked');
|
||||
}
|
||||
if (this.focused())
|
||||
{
|
||||
if (this.focused()) {
|
||||
result.push('focused');
|
||||
}
|
||||
|
||||
|
|
@ -124,4 +107,4 @@ class ContactModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {ContactModel, ContactModel as default};
|
||||
export { ContactModel, ContactModel as default };
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {ContactPropertyType} from 'Common/Enums';
|
||||
import {pInt, pString} from 'Common/Utils';
|
||||
import {i18n} from 'Common/Translator';
|
||||
import { ContactPropertyType } from 'Common/Enums';
|
||||
import { pInt, pString } from 'Common/Utils';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class ContactPropertyModel extends AbstractModel
|
||||
{
|
||||
class ContactPropertyModel extends AbstractModel {
|
||||
/**
|
||||
* @param {number=} type = Enums.ContactPropertyType.Unknown
|
||||
* @param {string=} typeStr = ''
|
||||
|
|
@ -16,8 +14,7 @@ class ContactPropertyModel extends AbstractModel
|
|||
* @param {boolean=} focused = false
|
||||
* @param {string=} placeholder = ''
|
||||
*/
|
||||
constructor(type = ContactPropertyType.Unknown, typeStr = '', value = '', focused = false, placeholder = '')
|
||||
{
|
||||
constructor(type = ContactPropertyType.Unknown, typeStr = '', value = '', focused = false, placeholder = '') {
|
||||
super('ContactPropertyModel');
|
||||
|
||||
this.type = ko.observable(pInt(type));
|
||||
|
|
@ -38,4 +35,4 @@ class ContactPropertyModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {ContactPropertyModel, ContactPropertyModel as default};
|
||||
export { ContactPropertyModel, ContactPropertyModel as default };
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
|
||||
import _ from '_';
|
||||
import addressparser from 'emailjs-addressparser';
|
||||
import {trim, encodeHtml, isNonEmptyArray} from 'Common/Utils';
|
||||
import { trim, encodeHtml, isNonEmptyArray } from 'Common/Utils';
|
||||
|
||||
class EmailModel
|
||||
{
|
||||
class EmailModel {
|
||||
email = '';
|
||||
name = '';
|
||||
dkimStatus = '';
|
||||
|
|
@ -16,8 +14,7 @@ class EmailModel
|
|||
* @param {string=} dkimStatus = 'none'
|
||||
* @param {string=} dkimValue = ''
|
||||
*/
|
||||
constructor(email = '', name = '', dkimStatus = 'none', dkimValue = '')
|
||||
{
|
||||
constructor(email = '', name = '', dkimStatus = 'none', dkimValue = '') {
|
||||
this.email = email;
|
||||
this.name = name;
|
||||
this.dkimStatus = dkimStatus;
|
||||
|
|
@ -66,8 +63,7 @@ class EmailModel
|
|||
* @returns {void}
|
||||
*/
|
||||
clearDuplicateName() {
|
||||
if (this.name === this.email)
|
||||
{
|
||||
if (this.name === this.email) {
|
||||
this.name = '';
|
||||
}
|
||||
}
|
||||
|
|
@ -86,8 +82,7 @@ class EmailModel
|
|||
*/
|
||||
initByJson(json) {
|
||||
let result = false;
|
||||
if (json && 'Object/Email' === json['@Object'])
|
||||
{
|
||||
if (json && 'Object/Email' === json['@Object']) {
|
||||
this.name = trim(json.Name);
|
||||
this.email = trim(json.Email);
|
||||
this.dkimStatus = trim(json.DkimStatus || '');
|
||||
|
|
@ -108,24 +103,31 @@ class EmailModel
|
|||
*/
|
||||
toLine(friendlyView, wrapWithLink = false, useEncodeHtml = false) {
|
||||
let result = '';
|
||||
if ('' !== this.email)
|
||||
{
|
||||
if (friendlyView && '' !== this.name)
|
||||
{
|
||||
result = wrapWithLink ? '<a href="mailto:' + encodeHtml(this.email) + '?to=' + encodeHtml('"' + this.name + '" <' + this.email + '>') +
|
||||
'" target="_blank" tabindex="-1">' + encodeHtml(this.name) + '</a>' : (useEncodeHtml ? encodeHtml(this.name) : this.name);
|
||||
if ('' !== this.email) {
|
||||
if (friendlyView && '' !== this.name) {
|
||||
result = wrapWithLink
|
||||
? '<a href="mailto:' +
|
||||
encodeHtml(this.email) +
|
||||
'?to=' +
|
||||
encodeHtml('"' + this.name + '" <' + this.email + '>') +
|
||||
'" target="_blank" tabindex="-1">' +
|
||||
encodeHtml(this.name) +
|
||||
'</a>'
|
||||
: useEncodeHtml
|
||||
? encodeHtml(this.name)
|
||||
: this.name;
|
||||
// result = wrapWithLink ? '<a href="mailto:' + encodeHtml('"' + this.name + '" <' + this.email + '>') +
|
||||
// '" target="_blank" tabindex="-1">' + encodeHtml(this.name) + '</a>' : (useEncodeHtml ? encodeHtml(this.name) : this.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
result = this.email;
|
||||
if ('' !== this.name)
|
||||
{
|
||||
if (wrapWithLink)
|
||||
{
|
||||
result = encodeHtml('"' + this.name + '" <') + '<a href="mailto:' +
|
||||
encodeHtml(this.email) + '?to=' + encodeHtml('"' + this.name + '" <' + this.email + '>') +
|
||||
if ('' !== this.name) {
|
||||
if (wrapWithLink) {
|
||||
result =
|
||||
encodeHtml('"' + this.name + '" <') +
|
||||
'<a href="mailto:' +
|
||||
encodeHtml(this.email) +
|
||||
'?to=' +
|
||||
encodeHtml('"' + this.name + '" <' + this.email + '>') +
|
||||
'" target="_blank" tabindex="-1">' +
|
||||
encodeHtml(result) +
|
||||
'</a>' +
|
||||
|
|
@ -136,19 +138,19 @@ class EmailModel
|
|||
// encodeHtml(result) +
|
||||
// '</a>' +
|
||||
// encodeHtml('>');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
result = '"' + this.name + '" <' + result + '>';
|
||||
if (useEncodeHtml)
|
||||
{
|
||||
if (useEncodeHtml) {
|
||||
result = encodeHtml(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (wrapWithLink)
|
||||
{
|
||||
result = '<a href="mailto:' + encodeHtml(this.email) + '" target="_blank" tabindex="-1">' + encodeHtml(this.email) + '</a>';
|
||||
} else if (wrapWithLink) {
|
||||
result =
|
||||
'<a href="mailto:' +
|
||||
encodeHtml(this.email) +
|
||||
'" target="_blank" tabindex="-1">' +
|
||||
encodeHtml(this.email) +
|
||||
'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -158,15 +160,13 @@ class EmailModel
|
|||
|
||||
static splitEmailLine(line) {
|
||||
const parsedResult = addressparser(line);
|
||||
if (isNonEmptyArray(parsedResult))
|
||||
{
|
||||
if (isNonEmptyArray(parsedResult)) {
|
||||
const result = [];
|
||||
let exists = false;
|
||||
parsedResult.forEach((item) => {
|
||||
const address = item.address ? new EmailModel(
|
||||
item.address.replace(/^[<]+(.*)[>]+$/g, '$1'),
|
||||
item.name || ''
|
||||
) : null;
|
||||
const address = item.address
|
||||
? new EmailModel(item.address.replace(/^[<]+(.*)[>]+$/g, '$1'), item.name || '')
|
||||
: null;
|
||||
|
||||
if (address && address.email) {
|
||||
exists = true;
|
||||
|
|
@ -183,14 +183,12 @@ class EmailModel
|
|||
|
||||
static parseEmailLine(line) {
|
||||
const parsedResult = addressparser(line);
|
||||
if (isNonEmptyArray(parsedResult))
|
||||
{
|
||||
return _.compact(parsedResult.map(
|
||||
(item) => (item.address ? new EmailModel(
|
||||
item.address.replace(/^[<]+(.*)[>]+$/g, '$1'),
|
||||
item.name || ''
|
||||
) : null)
|
||||
));
|
||||
if (isNonEmptyArray(parsedResult)) {
|
||||
return _.compact(
|
||||
parsedResult.map((item) =>
|
||||
item.address ? new EmailModel(item.address.replace(/^[<]+(.*)[>]+$/g, '$1'), item.name || '') : null
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return [];
|
||||
|
|
@ -202,14 +200,12 @@ class EmailModel
|
|||
*/
|
||||
parse(emailAddress) {
|
||||
emailAddress = trim(emailAddress);
|
||||
if ('' === emailAddress)
|
||||
{
|
||||
if ('' === emailAddress) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const result = addressparser(emailAddress);
|
||||
if (isNonEmptyArray(result) && result[0])
|
||||
{
|
||||
if (isNonEmptyArray(result) && result[0]) {
|
||||
this.name = result[0].name || '';
|
||||
this.email = result[0].address || '';
|
||||
this.clearDuplicateName();
|
||||
|
|
@ -221,4 +217,4 @@ class EmailModel
|
|||
}
|
||||
}
|
||||
|
||||
export {EmailModel, EmailModel as default};
|
||||
export { EmailModel, EmailModel as default };
|
||||
|
|
|
|||
|
|
@ -1,19 +1,17 @@
|
|||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {FilterRulesType, FiltersAction} from 'Common/Enums';
|
||||
import {pString, inArray, isNonEmptyArray, fakeMd5, delegateRunOnDestroy, windowResizeCallback} from 'Common/Utils';
|
||||
import {i18n} from 'Common/Translator';
|
||||
import {getFolderFromCacheList} from 'Common/Cache';
|
||||
import { FilterRulesType, FiltersAction } from 'Common/Enums';
|
||||
import { pString, inArray, isNonEmptyArray, fakeMd5, delegateRunOnDestroy, windowResizeCallback } from 'Common/Utils';
|
||||
import { i18n } from 'Common/Translator';
|
||||
import { getFolderFromCacheList } from 'Common/Cache';
|
||||
|
||||
import AccountStore from 'Stores/User/Account';
|
||||
|
||||
import {FilterConditionModel} from 'Model/FilterCondition';
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { FilterConditionModel } from 'Model/FilterCondition';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class FilterModel extends AbstractModel
|
||||
{
|
||||
class FilterModel extends AbstractModel {
|
||||
constructor() {
|
||||
super('FilterModel');
|
||||
|
||||
|
|
@ -56,15 +54,14 @@ class FilterModel extends AbstractModel
|
|||
|
||||
const fGetRealFolderName = (folderFullNameRaw) => {
|
||||
const folder = getFolderFromCacheList(folderFullNameRaw);
|
||||
return folder ? folder.fullName.replace('.' === folder.delimiter ? /\./ : /[\\\/]+/, ' / ') : folderFullNameRaw;
|
||||
return folder ? folder.fullName.replace('.' === folder.delimiter ? /\./ : /[\\/]+/, ' / ') : folderFullNameRaw;
|
||||
};
|
||||
|
||||
this.nameSub = ko.computed(() => {
|
||||
let result = '';
|
||||
const actionValue = this.actionValue();
|
||||
|
||||
switch (this.actionType())
|
||||
{
|
||||
switch (this.actionType()) {
|
||||
case FiltersAction.MoveTo:
|
||||
result = i18n('SETTINGS_FILTERS/SUBNAME_MOVE_TO', {
|
||||
FOLDER: fGetRealFolderName(actionValue)
|
||||
|
|
@ -93,8 +90,7 @@ class FilterModel extends AbstractModel
|
|||
this.actionTemplate = ko.computed(() => {
|
||||
let result = '';
|
||||
|
||||
switch (this.actionType())
|
||||
{
|
||||
switch (this.actionType()) {
|
||||
case FiltersAction.Forward:
|
||||
result = 'SettingsFiltersActionForward';
|
||||
break;
|
||||
|
|
@ -121,13 +117,17 @@ class FilterModel extends AbstractModel
|
|||
|
||||
this.regDisposables(this.conditions.subscribe(windowResizeCallback));
|
||||
|
||||
this.regDisposables(this.name.subscribe((sValue) => {
|
||||
this.name.error('' === sValue);
|
||||
}));
|
||||
this.regDisposables(
|
||||
this.name.subscribe((sValue) => {
|
||||
this.name.error('' === sValue);
|
||||
})
|
||||
);
|
||||
|
||||
this.regDisposables(this.actionValue.subscribe((sValue) => {
|
||||
this.actionValue.error('' === sValue);
|
||||
}));
|
||||
this.regDisposables(
|
||||
this.actionValue.subscribe((sValue) => {
|
||||
this.actionValue.error('' === sValue);
|
||||
})
|
||||
);
|
||||
|
||||
this.regDisposables([this.actionNoStop, this.actionTemplate]);
|
||||
|
||||
|
|
@ -140,42 +140,42 @@ class FilterModel extends AbstractModel
|
|||
}
|
||||
|
||||
verify() {
|
||||
if ('' === this.name())
|
||||
{
|
||||
if ('' === this.name()) {
|
||||
this.name.error(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 < this.conditions().length)
|
||||
{
|
||||
if (_.find(this.conditions(), (cond) => cond && !cond.verify()))
|
||||
{
|
||||
if (0 < this.conditions().length) {
|
||||
if (_.find(this.conditions(), (cond) => cond && !cond.verify())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ('' === this.actionValue())
|
||||
{
|
||||
if (-1 < inArray(this.actionType(), [
|
||||
FiltersAction.MoveTo, FiltersAction.Forward, FiltersAction.Reject, FiltersAction.Vacation
|
||||
]))
|
||||
{
|
||||
if ('' === this.actionValue()) {
|
||||
if (
|
||||
-1 <
|
||||
inArray(this.actionType(), [
|
||||
FiltersAction.MoveTo,
|
||||
FiltersAction.Forward,
|
||||
FiltersAction.Reject,
|
||||
FiltersAction.Vacation
|
||||
])
|
||||
) {
|
||||
this.actionValue.error(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (FiltersAction.Forward === this.actionType() &&
|
||||
-1 === this.actionValue().indexOf('@'))
|
||||
{
|
||||
if (FiltersAction.Forward === this.actionType() && -1 === this.actionValue().indexOf('@')) {
|
||||
this.actionValue.error(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FiltersAction.Vacation === this.actionType() &&
|
||||
'' !== this.actionValueFourth() && -1 === this.actionValueFourth().indexOf('@')
|
||||
)
|
||||
{
|
||||
if (
|
||||
FiltersAction.Vacation === this.actionType() &&
|
||||
'' !== this.actionValueFourth() &&
|
||||
-1 === this.actionValueFourth().indexOf('@')
|
||||
) {
|
||||
this.actionValueFourth.error(true);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -221,8 +221,7 @@ class FilterModel extends AbstractModel
|
|||
|
||||
parse(json) {
|
||||
let result = false;
|
||||
if (json && 'Object/Filter' === json['@Object'])
|
||||
{
|
||||
if (json && 'Object/Filter' === json['@Object']) {
|
||||
this.id = pString(json.ID);
|
||||
this.name(pString(json.Name));
|
||||
this.enabled(!!json.Enabled);
|
||||
|
|
@ -231,12 +230,15 @@ class FilterModel extends AbstractModel
|
|||
|
||||
this.conditions([]);
|
||||
|
||||
if (isNonEmptyArray(json.Conditions))
|
||||
{
|
||||
this.conditions(_.compact(_.map(json.Conditions, (aData) => {
|
||||
const filterCondition = new FilterConditionModel();
|
||||
return filterCondition && filterCondition.parse(aData) ? filterCondition : null;
|
||||
})));
|
||||
if (isNonEmptyArray(json.Conditions)) {
|
||||
this.conditions(
|
||||
_.compact(
|
||||
_.map(json.Conditions, (aData) => {
|
||||
const filterCondition = new FilterConditionModel();
|
||||
return filterCondition && filterCondition.parse(aData) ? filterCondition : null;
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
this.actionType(pString(json.ActionType));
|
||||
|
|
@ -257,7 +259,6 @@ class FilterModel extends AbstractModel
|
|||
}
|
||||
|
||||
cloneSelf() {
|
||||
|
||||
const filter = new FilterModel();
|
||||
|
||||
filter.id = this.id;
|
||||
|
|
@ -289,4 +290,4 @@ class FilterModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {FilterModel, FilterModel as default};
|
||||
export { FilterModel, FilterModel as default };
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {FilterConditionField, FilterConditionType} from 'Common/Enums';
|
||||
import {pString} from 'Common/Utils';
|
||||
import { FilterConditionField, FilterConditionType } from 'Common/Enums';
|
||||
import { pString } from 'Common/Utils';
|
||||
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class FilterConditionModel extends AbstractModel
|
||||
{
|
||||
class FilterConditionModel extends AbstractModel {
|
||||
constructor() {
|
||||
super('FilterConditionModel');
|
||||
|
||||
|
|
@ -20,10 +18,8 @@ class FilterConditionModel extends AbstractModel
|
|||
this.valueSecond.error = ko.observable(false);
|
||||
|
||||
this.template = ko.computed(() => {
|
||||
|
||||
let template = '';
|
||||
switch (this.field())
|
||||
{
|
||||
switch (this.field()) {
|
||||
case FilterConditionField.Size:
|
||||
template = 'SettingsFiltersConditionSize';
|
||||
break;
|
||||
|
|
@ -36,7 +32,6 @@ class FilterConditionModel extends AbstractModel
|
|||
}
|
||||
|
||||
return template;
|
||||
|
||||
}, this);
|
||||
|
||||
this.field.subscribe(() => {
|
||||
|
|
@ -48,14 +43,12 @@ class FilterConditionModel extends AbstractModel
|
|||
}
|
||||
|
||||
verify() {
|
||||
if ('' === this.value())
|
||||
{
|
||||
if ('' === this.value()) {
|
||||
this.value.error(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FilterConditionField.Header === this.field() && '' === this.valueSecond())
|
||||
{
|
||||
if (FilterConditionField.Header === this.field() && '' === this.valueSecond()) {
|
||||
this.valueSecond.error(true);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -64,8 +57,7 @@ class FilterConditionModel extends AbstractModel
|
|||
}
|
||||
|
||||
parse(json) {
|
||||
if (json && json.Field && json.Type)
|
||||
{
|
||||
if (json && json.Field && json.Type) {
|
||||
this.field(pString(json.Field));
|
||||
this.type(pString(json.Type));
|
||||
this.value(pString(json.Value));
|
||||
|
|
@ -98,4 +90,4 @@ class FilterConditionModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {FilterConditionModel, FilterConditionModel as default};
|
||||
export { FilterConditionModel, FilterConditionModel as default };
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {FolderType} from 'Common/Enums';
|
||||
import {isPosNumeric} from 'Common/Utils';
|
||||
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
|
||||
import {getFolderInboxName} from 'Common/Cache';
|
||||
import { FolderType } from 'Common/Enums';
|
||||
import { isPosNumeric } from 'Common/Utils';
|
||||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
import { getFolderInboxName } from 'Common/Cache';
|
||||
import * as Events from 'Common/Events';
|
||||
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class FolderModel extends AbstractModel
|
||||
{
|
||||
class FolderModel extends AbstractModel {
|
||||
constructor() {
|
||||
super('FolderModel');
|
||||
|
||||
|
|
@ -36,7 +34,7 @@ class FolderModel extends AbstractModel
|
|||
this.checkable = ko.observable(false);
|
||||
this.subFolders = ko.observableArray([]);
|
||||
this.deleteAccess = ko.observable(false);
|
||||
this.actionBlink = ko.observable(false).extend({falseTimeout: 1000});
|
||||
this.actionBlink = ko.observable(false).extend({ falseTimeout: 1000 });
|
||||
|
||||
this.nameForEdit = ko.observable('');
|
||||
|
||||
|
|
@ -65,24 +63,26 @@ class FolderModel extends AbstractModel
|
|||
this.isInbox = ko.computed(() => FolderType.Inbox === this.type());
|
||||
|
||||
this.hasSubScribedSubfolders = ko.computed(
|
||||
() => !!_.find(this.subFolders(), (oFolder) => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder())
|
||||
() =>
|
||||
!!_.find(
|
||||
this.subFolders(),
|
||||
(oFolder) => (oFolder.subScribed() || oFolder.hasSubScribedSubfolders()) && !oFolder.isSystemFolder()
|
||||
)
|
||||
);
|
||||
|
||||
this.canBeEdited = ko.computed(() => FolderType.User === this.type() && this.existen && this.selectable);
|
||||
|
||||
this.visible = ko.computed(() => {
|
||||
const
|
||||
isSubScribed = this.subScribed(),
|
||||
const isSubScribed = this.subScribed(),
|
||||
isSubFolders = this.hasSubScribedSubfolders();
|
||||
|
||||
return (isSubScribed || (isSubFolders && (!this.existen || !this.selectable)));
|
||||
return isSubScribed || (isSubFolders && (!this.existen || !this.selectable));
|
||||
});
|
||||
|
||||
this.isSystemFolder = ko.computed(() => FolderType.User !== this.type());
|
||||
|
||||
this.hidden = ko.computed(() => {
|
||||
const
|
||||
isSystem = this.isSystemFolder(),
|
||||
const isSystem = this.isSystemFolder(),
|
||||
isSubFolders = this.hasSubScribedSubfolders();
|
||||
|
||||
return (isSystem && !isSubFolders) || (!this.selectable && !isSubFolders);
|
||||
|
|
@ -90,48 +90,46 @@ class FolderModel extends AbstractModel
|
|||
|
||||
this.selectableForFolderList = ko.computed(() => !this.isSystemFolder() && this.selectable);
|
||||
|
||||
this.messageCountAll = ko.computed({
|
||||
read: this.privateMessageCountAll,
|
||||
write: (iValue) => {
|
||||
if (isPosNumeric(iValue, true))
|
||||
{
|
||||
this.privateMessageCountAll(iValue);
|
||||
this.messageCountAll = ko
|
||||
.computed({
|
||||
read: this.privateMessageCountAll,
|
||||
write: (iValue) => {
|
||||
if (isPosNumeric(iValue, true)) {
|
||||
this.privateMessageCountAll(iValue);
|
||||
} else {
|
||||
this.privateMessageCountAll.valueHasMutated();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.privateMessageCountAll.valueHasMutated();
|
||||
}
|
||||
}
|
||||
}).extend({notify: 'always'});
|
||||
})
|
||||
.extend({ notify: 'always' });
|
||||
|
||||
this.messageCountUnread = ko.computed({
|
||||
read: this.privateMessageCountUnread,
|
||||
write: (value) => {
|
||||
if (isPosNumeric(value, true))
|
||||
{
|
||||
this.privateMessageCountUnread(value);
|
||||
this.messageCountUnread = ko
|
||||
.computed({
|
||||
read: this.privateMessageCountUnread,
|
||||
write: (value) => {
|
||||
if (isPosNumeric(value, true)) {
|
||||
this.privateMessageCountUnread(value);
|
||||
} else {
|
||||
this.privateMessageCountUnread.valueHasMutated();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.privateMessageCountUnread.valueHasMutated();
|
||||
}
|
||||
}
|
||||
}).extend({notify: 'always'});
|
||||
})
|
||||
.extend({ notify: 'always' });
|
||||
|
||||
this.printableUnreadCount = ko.computed(() => {
|
||||
const
|
||||
count = this.messageCountAll(),
|
||||
const count = this.messageCountAll(),
|
||||
unread = this.messageCountUnread(),
|
||||
type = this.type();
|
||||
|
||||
if (0 < count)
|
||||
{
|
||||
if (FolderType.Draft === type)
|
||||
{
|
||||
if (0 < count) {
|
||||
if (FolderType.Draft === type) {
|
||||
return '' + count;
|
||||
}
|
||||
else if (0 < unread && FolderType.Trash !== type && FolderType.Archive !== type && FolderType.SentItems !== type)
|
||||
{
|
||||
} else if (
|
||||
0 < unread &&
|
||||
FolderType.Trash !== type &&
|
||||
FolderType.Archive !== type &&
|
||||
FolderType.SentItems !== type
|
||||
) {
|
||||
return '' + unread;
|
||||
}
|
||||
}
|
||||
|
|
@ -144,21 +142,20 @@ class FolderModel extends AbstractModel
|
|||
return !bSystem && 0 === this.subFolders().length && inboxFolderName !== this.fullNameRaw;
|
||||
});
|
||||
|
||||
this.canBeSubScribed = ko.computed(() => !this.isSystemFolder() && this.selectable && inboxFolderName !== this.fullNameRaw);
|
||||
this.canBeSubScribed = ko.computed(
|
||||
() => !this.isSystemFolder() && this.selectable && inboxFolderName !== this.fullNameRaw
|
||||
);
|
||||
|
||||
this.canBeChecked = this.canBeSubScribed;
|
||||
|
||||
this.localName = ko.computed(() => {
|
||||
|
||||
translatorTrigger();
|
||||
|
||||
let name = this.name();
|
||||
const type = this.type();
|
||||
|
||||
if (this.isSystemFolder())
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
if (this.isSystemFolder()) {
|
||||
switch (type) {
|
||||
case FolderType.Inbox:
|
||||
name = i18n('FOLDER_LIST/INBOX_NAME');
|
||||
break;
|
||||
|
|
@ -185,18 +182,14 @@ class FolderModel extends AbstractModel
|
|||
});
|
||||
|
||||
this.manageFolderSystemName = ko.computed(() => {
|
||||
|
||||
translatorTrigger();
|
||||
|
||||
let suffix = '';
|
||||
const
|
||||
type = this.type(),
|
||||
const type = this.type(),
|
||||
name = this.name();
|
||||
|
||||
if (this.isSystemFolder())
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
if (this.isSystemFolder()) {
|
||||
switch (type) {
|
||||
case FolderType.Inbox:
|
||||
suffix = '(' + i18n('FOLDER_LIST/INBOX_NAME') + ')';
|
||||
break;
|
||||
|
|
@ -219,8 +212,7 @@ class FolderModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
if ('' !== suffix && '(' + name + ')' === suffix || '(inbox)' === suffix.toLowerCase())
|
||||
{
|
||||
if (('' !== suffix && '(' + name + ')' === suffix) || '(inbox)' === suffix.toLowerCase()) {
|
||||
suffix = '';
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +229,11 @@ class FolderModel extends AbstractModel
|
|||
this.hasUnreadMessages = ko.computed(() => 0 < this.messageCountUnread() && '' !== this.printableUnreadCount());
|
||||
|
||||
this.hasSubScribedUnreadMessagesSubfolders = ko.computed(
|
||||
() => !!_.find(this.subFolders(), (folder) => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders())
|
||||
() =>
|
||||
!!_.find(
|
||||
this.subFolders(),
|
||||
(folder) => folder.hasUnreadMessages() || folder.hasSubScribedUnreadMessagesSubfolders()
|
||||
)
|
||||
);
|
||||
|
||||
// subscribe
|
||||
|
|
@ -246,15 +242,13 @@ class FolderModel extends AbstractModel
|
|||
});
|
||||
|
||||
this.edited.subscribe((value) => {
|
||||
if (value)
|
||||
{
|
||||
if (value) {
|
||||
this.nameForEdit(this.name());
|
||||
}
|
||||
});
|
||||
|
||||
this.messageCountUnread.subscribe((unread) => {
|
||||
if (FolderType.Inbox === this.type())
|
||||
{
|
||||
if (FolderType.Inbox === this.type()) {
|
||||
Events.pub('mailbox.inbox-unread-count', [unread]);
|
||||
}
|
||||
});
|
||||
|
|
@ -266,8 +260,11 @@ class FolderModel extends AbstractModel
|
|||
* @returns {string}
|
||||
*/
|
||||
collapsedCss() {
|
||||
return this.hasSubScribedSubfolders() ?
|
||||
(this.collapsed() ? 'icon-right-mini e-collapsed-sign' : 'icon-down-mini e-collapsed-sign') : 'icon-none e-collapsed-sign';
|
||||
return this.hasSubScribedSubfolders()
|
||||
? this.collapsed()
|
||||
? 'icon-right-mini e-collapsed-sign'
|
||||
: 'icon-down-mini e-collapsed-sign'
|
||||
: 'icon-none e-collapsed-sign';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -278,8 +275,7 @@ class FolderModel extends AbstractModel
|
|||
let bResult = false;
|
||||
const sInboxFolderName = getFolderInboxName();
|
||||
|
||||
if (json && 'Object/Folder' === json['@Object'])
|
||||
{
|
||||
if (json && 'Object/Folder' === json['@Object']) {
|
||||
this.name(json.Name);
|
||||
this.delimiter = json.Delimiter;
|
||||
this.fullName = json.FullName;
|
||||
|
|
@ -308,4 +304,4 @@ class FolderModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {FolderModel, FolderModel as default};
|
||||
export { FolderModel, FolderModel as default };
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class IdentityModel extends AbstractModel
|
||||
{
|
||||
class IdentityModel extends AbstractModel {
|
||||
/**
|
||||
* @param {string} id
|
||||
* @param {string} email
|
||||
*/
|
||||
constructor(id, email)
|
||||
{
|
||||
constructor(id, email) {
|
||||
super('IdentityModel');
|
||||
|
||||
this.id = ko.observable(id || '');
|
||||
|
|
@ -31,12 +28,11 @@ class IdentityModel extends AbstractModel
|
|||
* @returns {string}
|
||||
*/
|
||||
formattedName() {
|
||||
const
|
||||
name = this.name(),
|
||||
const name = this.name(),
|
||||
email = this.email();
|
||||
|
||||
return '' !== name ? name + ' (' + email + ')' : email;
|
||||
}
|
||||
}
|
||||
|
||||
export {IdentityModel, IdentityModel as default};
|
||||
export { IdentityModel, IdentityModel as default };
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
|
|
@ -6,28 +5,34 @@ import moment from 'moment';
|
|||
import classnames from 'classnames';
|
||||
import lozad from 'lozad';
|
||||
|
||||
import {MessagePriority, SignedVerifyStatus} from 'Common/Enums';
|
||||
import {i18n} from 'Common/Translator';
|
||||
import {DATA_IMAGE_LAZY_PLACEHOLDER_PIC} from 'Common/Consts';
|
||||
import { MessagePriority, SignedVerifyStatus } from 'Common/Enums';
|
||||
import { i18n } from 'Common/Translator';
|
||||
import { DATA_IMAGE_LAZY_PLACEHOLDER_PIC } from 'Common/Consts';
|
||||
|
||||
import {
|
||||
pInt, inArray, isArray, isUnd, trim,
|
||||
previewMessage, windowResize, friendlySize, isNonEmptyArray
|
||||
pInt,
|
||||
inArray,
|
||||
isArray,
|
||||
isUnd,
|
||||
trim,
|
||||
previewMessage,
|
||||
windowResize,
|
||||
friendlySize,
|
||||
isNonEmptyArray
|
||||
} from 'Common/Utils';
|
||||
|
||||
import {$win} from 'Common/Globals';
|
||||
import {messageViewLink, messageDownloadLink} from 'Common/Links';
|
||||
import { $win } from 'Common/Globals';
|
||||
import { messageViewLink, messageDownloadLink } from 'Common/Links';
|
||||
|
||||
import FolderStore from 'Stores/User/Folder';
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
|
||||
import {emailArrayFromJson, emailArrayToStringClear, emailArrayToString, replyHelper} from 'Helper/Message';
|
||||
import { emailArrayFromJson, emailArrayToStringClear, emailArrayToString, replyHelper } from 'Helper/Message';
|
||||
|
||||
import {AttachmentModel, staticCombinedIconClass} from 'Model/Attachment';
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AttachmentModel, staticCombinedIconClass } from 'Model/Attachment';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class MessageModel extends AbstractModel
|
||||
{
|
||||
class MessageModel extends AbstractModel {
|
||||
constructor() {
|
||||
super('MessageModel');
|
||||
|
||||
|
|
@ -78,7 +83,9 @@ class MessageModel extends AbstractModel
|
|||
this.hasAttachments = ko.observable(false);
|
||||
this.attachmentsSpecData = ko.observableArray([]);
|
||||
|
||||
this.attachmentIconClass = ko.computed(() => staticCombinedIconClass(this.hasAttachments() ? this.attachmentsSpecData() : []));
|
||||
this.attachmentIconClass = ko.computed(() =>
|
||||
staticCombinedIconClass(this.hasAttachments() ? this.attachmentsSpecData() : [])
|
||||
);
|
||||
|
||||
this.body = null;
|
||||
|
||||
|
|
@ -194,10 +201,13 @@ class MessageModel extends AbstractModel
|
|||
* @returns {Array}
|
||||
*/
|
||||
getEmails(properties) {
|
||||
return _.compact(_.uniq(_.map(
|
||||
_.reduce(properties, (carry, property) => carry.concat(this[property]), []),
|
||||
(oItem) => (oItem ? oItem.email : '')
|
||||
)));
|
||||
return _.compact(
|
||||
_.uniq(
|
||||
_.map(_.reduce(properties, (carry, property) => carry.concat(this[property]), []), (oItem) =>
|
||||
oItem ? oItem.email : ''
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -215,15 +225,20 @@ class MessageModel extends AbstractModel
|
|||
}
|
||||
|
||||
computeSenderEmail() {
|
||||
const
|
||||
sentFolder = FolderStore.sentFolder(),
|
||||
const sentFolder = FolderStore.sentFolder(),
|
||||
draftFolder = FolderStore.draftFolder();
|
||||
|
||||
this.senderEmailsString(this.folderFullNameRaw === sentFolder || this.folderFullNameRaw === draftFolder ?
|
||||
this.toEmailsString() : this.fromEmailString());
|
||||
this.senderEmailsString(
|
||||
this.folderFullNameRaw === sentFolder || this.folderFullNameRaw === draftFolder
|
||||
? this.toEmailsString()
|
||||
: this.fromEmailString()
|
||||
);
|
||||
|
||||
this.senderClearEmailsString(this.folderFullNameRaw === sentFolder || this.folderFullNameRaw === draftFolder ?
|
||||
this.toClearEmailsString() : this.fromClearEmailString());
|
||||
this.senderClearEmailsString(
|
||||
this.folderFullNameRaw === sentFolder || this.folderFullNameRaw === draftFolder
|
||||
? this.toClearEmailsString()
|
||||
: this.fromClearEmailString()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -231,14 +246,14 @@ class MessageModel extends AbstractModel
|
|||
* @returns {boolean}
|
||||
*/
|
||||
initByJson(json) {
|
||||
let
|
||||
result = false,
|
||||
let result = false,
|
||||
priority = MessagePriority.Normal;
|
||||
|
||||
if (json && 'Object/Message' === json['@Object'])
|
||||
{
|
||||
if (json && 'Object/Message' === json['@Object']) {
|
||||
priority = pInt(json.Priority);
|
||||
this.priority(-1 < inArray(priority, [MessagePriority.High, MessagePriority.Low]) ? priority : MessagePriority.Normal);
|
||||
this.priority(
|
||||
-1 < inArray(priority, [MessagePriority.High, MessagePriority.Low]) ? priority : MessagePriority.Normal
|
||||
);
|
||||
|
||||
this.folderFullNameRaw = json.Folder;
|
||||
this.uid = json.Uid;
|
||||
|
|
@ -258,13 +273,10 @@ class MessageModel extends AbstractModel
|
|||
this.unsubsribeLinks = isNonEmptyArray(json.UnsubsribeLinks) ? json.UnsubsribeLinks : [];
|
||||
|
||||
this.subject(json.Subject);
|
||||
if (isArray(json.SubjectParts))
|
||||
{
|
||||
if (isArray(json.SubjectParts)) {
|
||||
this.subjectPrefix(json.SubjectParts[0]);
|
||||
this.subjectSuffix(json.SubjectParts[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.subjectPrefix('');
|
||||
this.subjectSuffix(this.subject());
|
||||
}
|
||||
|
|
@ -294,15 +306,14 @@ class MessageModel extends AbstractModel
|
|||
* @returns {boolean}
|
||||
*/
|
||||
initUpdateByMessageJson(json) {
|
||||
let
|
||||
result = false,
|
||||
let result = false,
|
||||
priority = MessagePriority.Normal;
|
||||
|
||||
if (json && 'Object/Message' === json['@Object'])
|
||||
{
|
||||
if (json && 'Object/Message' === json['@Object']) {
|
||||
priority = pInt(json.Priority);
|
||||
this.priority(-1 < inArray(priority, [MessagePriority.High, MessagePriority.Low]) ?
|
||||
priority : MessagePriority.Normal);
|
||||
this.priority(
|
||||
-1 < inArray(priority, [MessagePriority.High, MessagePriority.Low]) ? priority : MessagePriority.Normal
|
||||
);
|
||||
|
||||
this.aDraftInfo = json.DraftInfo;
|
||||
|
||||
|
|
@ -312,8 +323,7 @@ class MessageModel extends AbstractModel
|
|||
|
||||
this.proxy = !!json.ExternalProxy;
|
||||
|
||||
if (PgpStore.capaOpenPGP())
|
||||
{
|
||||
if (PgpStore.capaOpenPGP()) {
|
||||
this.isPgpSigned(!!json.PgpSigned);
|
||||
this.isPgpEncrypted(!!json.PgpEncrypted);
|
||||
}
|
||||
|
|
@ -339,22 +349,20 @@ class MessageModel extends AbstractModel
|
|||
* @returns {Array}
|
||||
*/
|
||||
initAttachmentsFromJson(json) {
|
||||
let
|
||||
index = 0,
|
||||
let index = 0,
|
||||
len = 0,
|
||||
attachment = null;
|
||||
const result = [];
|
||||
|
||||
if (json && 'Collection/AttachmentCollection' === json['@Object'] && isNonEmptyArray(json['@Collection']))
|
||||
{
|
||||
for (index = 0, len = json['@Collection'].length; index < len; index++)
|
||||
{
|
||||
if (json && 'Collection/AttachmentCollection' === json['@Object'] && isNonEmptyArray(json['@Collection'])) {
|
||||
for (index = 0, len = json['@Collection'].length; index < len; index++) {
|
||||
attachment = AttachmentModel.newInstanceFromJson(json['@Collection'][index]);
|
||||
if (attachment)
|
||||
{
|
||||
if ('' !== attachment.cidWithOutTags && 0 < this.foundedCIDs.length &&
|
||||
0 <= inArray(attachment.cidWithOutTags, this.foundedCIDs))
|
||||
{
|
||||
if (attachment) {
|
||||
if (
|
||||
'' !== attachment.cidWithOutTags &&
|
||||
0 < this.foundedCIDs.length &&
|
||||
0 <= inArray(attachment.cidWithOutTags, this.foundedCIDs)
|
||||
) {
|
||||
attachment.isLinked = true;
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +385,7 @@ class MessageModel extends AbstractModel
|
|||
* @returns {string}
|
||||
*/
|
||||
getFirstUnsubsribeLink() {
|
||||
return this.unsubsribeLinks && 0 < this.unsubsribeLinks.length ? (this.unsubsribeLinks[0] || '') : '';
|
||||
return this.unsubsribeLinks && 0 < this.unsubsribeLinks.length ? this.unsubsribeLinks[0] || '' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -386,8 +394,7 @@ class MessageModel extends AbstractModel
|
|||
*/
|
||||
initFlagsByJson(json) {
|
||||
let result = false;
|
||||
if (json && 'Object/Message' === json['@Object'])
|
||||
{
|
||||
if (json && 'Object/Message' === json['@Object']) {
|
||||
this.unseen(!json.IsSeen);
|
||||
this.flagged(!!json.IsFlagged);
|
||||
this.answered(!!json.IsAnswered);
|
||||
|
|
@ -415,8 +422,7 @@ class MessageModel extends AbstractModel
|
|||
*/
|
||||
fromDkimData() {
|
||||
let result = ['none', ''];
|
||||
if (isNonEmptyArray(this.from) && 1 === this.from.length && this.from[0] && this.from[0].dkimStatus)
|
||||
{
|
||||
if (isNonEmptyArray(this.from) && 1 === this.from.length && this.from[0] && this.from[0].dkimStatus) {
|
||||
result = [this.from[0].dkimStatus, this.from[0].dkimValue || ''];
|
||||
}
|
||||
|
||||
|
|
@ -498,8 +504,7 @@ class MessageModel extends AbstractModel
|
|||
let result = null;
|
||||
const attachments = this.attachments();
|
||||
|
||||
if (isNonEmptyArray(attachments))
|
||||
{
|
||||
if (isNonEmptyArray(attachments)) {
|
||||
cid = cid.replace(/^<+/, '').replace(/>+$/, '');
|
||||
result = _.find(attachments, (item) => cid === item.cidWithOutTags);
|
||||
}
|
||||
|
|
@ -515,8 +520,7 @@ class MessageModel extends AbstractModel
|
|||
let result = null;
|
||||
const attachments = this.attachments();
|
||||
|
||||
if (isNonEmptyArray(attachments))
|
||||
{
|
||||
if (isNonEmptyArray(attachments)) {
|
||||
result = _.find(attachments, (item) => contentLocation === item.contentLocation);
|
||||
}
|
||||
|
||||
|
|
@ -571,18 +575,15 @@ class MessageModel extends AbstractModel
|
|||
* @returns {Array}
|
||||
*/
|
||||
replyEmails(excludeEmails, last = false) {
|
||||
const
|
||||
result = [],
|
||||
const result = [],
|
||||
unic = isUnd(excludeEmails) ? {} : excludeEmails;
|
||||
|
||||
replyHelper(this.replyTo, unic, result);
|
||||
if (0 === result.length)
|
||||
{
|
||||
if (0 === result.length) {
|
||||
replyHelper(this.from, unic, result);
|
||||
}
|
||||
|
||||
if (0 === result.length && !last)
|
||||
{
|
||||
if (0 === result.length && !last) {
|
||||
return this.replyEmails({}, true);
|
||||
}
|
||||
|
||||
|
|
@ -596,22 +597,19 @@ class MessageModel extends AbstractModel
|
|||
*/
|
||||
replyAllEmails(excludeEmails, last = false) {
|
||||
let data = [];
|
||||
const
|
||||
toResult = [],
|
||||
const toResult = [],
|
||||
ccResult = [],
|
||||
unic = isUnd(excludeEmails) ? {} : excludeEmails;
|
||||
|
||||
replyHelper(this.replyTo, unic, toResult);
|
||||
if (0 === toResult.length)
|
||||
{
|
||||
if (0 === toResult.length) {
|
||||
replyHelper(this.from, unic, toResult);
|
||||
}
|
||||
|
||||
replyHelper(this.to, unic, toResult);
|
||||
replyHelper(this.cc, unic, ccResult);
|
||||
|
||||
if (0 === toResult.length && !last)
|
||||
{
|
||||
if (0 === toResult.length && !last) {
|
||||
data = this.replyAllEmails({}, true);
|
||||
return [data[0], ccResult];
|
||||
}
|
||||
|
|
@ -640,22 +638,26 @@ class MessageModel extends AbstractModel
|
|||
viewPopupMessage(print = false) {
|
||||
this.showLazyExternalImagesInBody();
|
||||
|
||||
const
|
||||
timeStampInUTC = this.dateTimeStampInUTC() || 0,
|
||||
const timeStampInUTC = this.dateTimeStampInUTC() || 0,
|
||||
ccLine = this.ccToLine(false),
|
||||
m = 0 < timeStampInUTC ? moment.unix(timeStampInUTC) : null;
|
||||
|
||||
previewMessage({
|
||||
title: this.subject(),
|
||||
subject: this.subject(),
|
||||
date: m ? m.format('LLL') : '',
|
||||
fromCreds: this.fromToLine(false),
|
||||
toLabel: i18n('MESSAGE/LABEL_TO'),
|
||||
toCreds: this.toToLine(false),
|
||||
ccClass: ccLine ? '' : 'rl-preview-hide',
|
||||
ccLabel: i18n('MESSAGE/LABEL_CC'),
|
||||
ccCreds: ccLine
|
||||
}, this.body, this.isHtml(), print);
|
||||
previewMessage(
|
||||
{
|
||||
title: this.subject(),
|
||||
subject: this.subject(),
|
||||
date: m ? m.format('LLL') : '',
|
||||
fromCreds: this.fromToLine(false),
|
||||
toLabel: i18n('MESSAGE/LABEL_TO'),
|
||||
toCreds: this.toToLine(false),
|
||||
ccClass: ccLine ? '' : 'rl-preview-hide',
|
||||
ccLabel: i18n('MESSAGE/LABEL_CC'),
|
||||
ccCreds: ccLine
|
||||
},
|
||||
this.body,
|
||||
this.isHtml(),
|
||||
print
|
||||
);
|
||||
}
|
||||
|
||||
printMessage() {
|
||||
|
|
@ -674,8 +676,7 @@ class MessageModel extends AbstractModel
|
|||
* @returns {MessageModel}
|
||||
*/
|
||||
populateByMessageListItem(message) {
|
||||
if (message)
|
||||
{
|
||||
if (message) {
|
||||
this.folderFullNameRaw = message.folderFullNameRaw;
|
||||
this.uid = message.uid;
|
||||
this.hash = message.hash;
|
||||
|
|
@ -686,8 +687,7 @@ class MessageModel extends AbstractModel
|
|||
this.subjectPrefix(this.subjectPrefix());
|
||||
this.subjectSuffix(this.subjectSuffix());
|
||||
|
||||
if (message)
|
||||
{
|
||||
if (message) {
|
||||
this.size(message.size());
|
||||
this.dateTimeStampInUTC(message.dateTimeStampInUTC());
|
||||
this.priority(message.priority());
|
||||
|
|
@ -731,8 +731,7 @@ class MessageModel extends AbstractModel
|
|||
this.sInReplyTo = '';
|
||||
this.sReferences = '';
|
||||
|
||||
if (message)
|
||||
{
|
||||
if (message) {
|
||||
this.threads(message.threads());
|
||||
}
|
||||
|
||||
|
|
@ -742,11 +741,12 @@ class MessageModel extends AbstractModel
|
|||
}
|
||||
|
||||
showLazyExternalImagesInBody() {
|
||||
if (this.body)
|
||||
{
|
||||
if (this.body) {
|
||||
$('.lazy.lazy-inited[data-original]', this.body).each(function() {
|
||||
$(this).attr('src', $(this).attr('data-original')) // eslint-disable-line no-invalid-this
|
||||
.removeAttr('data-original').removeAttr('data-loaded');
|
||||
$(this)
|
||||
.attr('src', $(this).attr('data-original')) // eslint-disable-line no-invalid-this
|
||||
.removeAttr('data-original')
|
||||
.removeAttr('data-loaded');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -762,32 +762,27 @@ class MessageModel extends AbstractModel
|
|||
.attr('src', element.dataset.original)
|
||||
.removeAttr('data-loaded')
|
||||
.removeAttr('data-original')
|
||||
.css({opacity: 0.3})
|
||||
.animate({opacity: 1}, 500);
|
||||
.css({ opacity: 0.3 })
|
||||
.animate({ opacity: 1 }, 500);
|
||||
}
|
||||
}).observe();
|
||||
}
|
||||
|
||||
showExternalImages(lazy = false) {
|
||||
if (this.body && this.body.data('rl-has-images'))
|
||||
{
|
||||
if (this.body && this.body.data('rl-has-images')) {
|
||||
this.hasImages(false);
|
||||
this.body.data('rl-has-images', false);
|
||||
|
||||
let attr = this.proxy ? 'data-x-additional-src' : 'data-x-src';
|
||||
$('[' + attr + ']', this.body).each(function() {
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
if (lazy && $this.is('img'))
|
||||
{
|
||||
if (lazy && $this.is('img')) {
|
||||
$this
|
||||
.addClass('lazy')
|
||||
.attr('data-original', $this.attr(attr))
|
||||
.removeAttr('data-loaded');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this.attr('src', $this.attr(attr))
|
||||
.removeAttr('data-loaded');
|
||||
} else {
|
||||
$this.attr('src', $this.attr(attr)).removeAttr('data-loaded');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -795,12 +790,11 @@ class MessageModel extends AbstractModel
|
|||
$('[' + attr + ']', this.body).each(function() {
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
let style = trim($this.attr('style'));
|
||||
style = '' === style ? '' : (';' === style.substr(-1) ? style + ' ' : style + '; ');
|
||||
style = '' === style ? '' : ';' === style.substr(-1) ? style + ' ' : style + '; ';
|
||||
$this.attr('style', style + $this.attr(attr));
|
||||
});
|
||||
|
||||
if (lazy)
|
||||
{
|
||||
if (lazy) {
|
||||
this.lozad();
|
||||
$win.resize();
|
||||
}
|
||||
|
|
@ -810,27 +804,19 @@ class MessageModel extends AbstractModel
|
|||
}
|
||||
|
||||
showInternalImages(lazy = false) {
|
||||
if (this.body && !this.body.data('rl-init-internal-images'))
|
||||
{
|
||||
if (this.body && !this.body.data('rl-init-internal-images')) {
|
||||
this.body.data('rl-init-internal-images', true);
|
||||
|
||||
const self = this;
|
||||
|
||||
$('[data-x-src-cid]', this.body).each(function() {
|
||||
const
|
||||
$this = $(this), // eslint-disable-line no-invalid-this
|
||||
const $this = $(this), // eslint-disable-line no-invalid-this
|
||||
attachment = self.findAttachmentByCid($this.attr('data-x-src-cid'));
|
||||
|
||||
if (attachment && attachment.download)
|
||||
{
|
||||
if (lazy && $this.is('img'))
|
||||
{
|
||||
$this
|
||||
.addClass('lazy')
|
||||
.attr('data-original', attachment.linkPreview());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (attachment && attachment.download) {
|
||||
if (lazy && $this.is('img')) {
|
||||
$this.addClass('lazy').attr('data-original', attachment.linkPreview());
|
||||
} else {
|
||||
$this.attr('src', attachment.linkPreview());
|
||||
}
|
||||
}
|
||||
|
|
@ -839,49 +825,37 @@ class MessageModel extends AbstractModel
|
|||
$('[data-x-src-location]', this.body).each(function() {
|
||||
const $this = $(this); // eslint-disable-line no-invalid-this
|
||||
let attachment = self.findAttachmentByContentLocation($this.attr('data-x-src-location'));
|
||||
if (!attachment)
|
||||
{
|
||||
if (!attachment) {
|
||||
attachment = self.findAttachmentByCid($this.attr('data-x-src-location'));
|
||||
}
|
||||
|
||||
if (attachment && attachment.download)
|
||||
{
|
||||
if (lazy && $this.is('img'))
|
||||
{
|
||||
$this
|
||||
.addClass('lazy')
|
||||
.attr('data-original', attachment.linkPreview());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (attachment && attachment.download) {
|
||||
if (lazy && $this.is('img')) {
|
||||
$this.addClass('lazy').attr('data-original', attachment.linkPreview());
|
||||
} else {
|
||||
$this.attr('src', attachment.linkPreview());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-x-style-cid]', this.body).each(function() {
|
||||
let
|
||||
style = '',
|
||||
let style = '',
|
||||
name = '';
|
||||
|
||||
const
|
||||
$this = $(this), // eslint-disable-line no-invalid-this
|
||||
const $this = $(this), // eslint-disable-line no-invalid-this
|
||||
attachment = self.findAttachmentByCid($this.attr('data-x-style-cid'));
|
||||
|
||||
if (attachment && attachment.linkPreview)
|
||||
{
|
||||
if (attachment && attachment.linkPreview) {
|
||||
name = $this.attr('data-x-style-cid-name');
|
||||
if ('' !== name)
|
||||
{
|
||||
if ('' !== name) {
|
||||
style = trim($this.attr('style'));
|
||||
style = '' === style ? '' : (';' === style.substr(-1) ? style + ' ' : style + '; ');
|
||||
$this.attr('style', style + name + ': url(\'' + attachment.linkPreview() + '\')');
|
||||
style = '' === style ? '' : ';' === style.substr(-1) ? style + ' ' : style + '; ';
|
||||
$this.attr('style', style + name + ": url('" + attachment.linkPreview() + "')");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (lazy)
|
||||
{
|
||||
if (lazy) {
|
||||
// $('.RL-MailMessageView .messageView .messageItem .content')[0]
|
||||
_.delay(() => this.lozad(), 300);
|
||||
}
|
||||
|
|
@ -891,24 +865,21 @@ class MessageModel extends AbstractModel
|
|||
}
|
||||
|
||||
storeDataInDom() {
|
||||
if (this.body)
|
||||
{
|
||||
if (this.body) {
|
||||
this.body.data('rl-is-html', !!this.isHtml());
|
||||
this.body.data('rl-has-images', !!this.hasImages());
|
||||
}
|
||||
}
|
||||
|
||||
fetchDataFromDom() {
|
||||
if (this.body)
|
||||
{
|
||||
if (this.body) {
|
||||
this.isHtml(!!this.body.data('rl-is-html'));
|
||||
this.hasImages(!!this.body.data('rl-has-images'));
|
||||
}
|
||||
}
|
||||
|
||||
replacePlaneTextBody(plain) {
|
||||
if (this.body)
|
||||
{
|
||||
if (this.body) {
|
||||
this.body.html(plain).addClass('b-text-part plain');
|
||||
}
|
||||
}
|
||||
|
|
@ -917,8 +888,16 @@ class MessageModel extends AbstractModel
|
|||
* @returns {string}
|
||||
*/
|
||||
flagHash() {
|
||||
return [this.deleted(), this.deletedMark(), this.unseen(), this.flagged(), this.answered(), this.forwarded(), this.isReadReceipt()].join(',');
|
||||
return [
|
||||
this.deleted(),
|
||||
this.deletedMark(),
|
||||
this.unseen(),
|
||||
this.flagged(),
|
||||
this.answered(),
|
||||
this.forwarded(),
|
||||
this.isReadReceipt()
|
||||
].join(',');
|
||||
}
|
||||
}
|
||||
|
||||
export {MessageModel, MessageModel as default};
|
||||
export { MessageModel, MessageModel as default };
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {isNonEmptyArray, log} from 'Common/Utils';
|
||||
import { isNonEmptyArray, log } from 'Common/Utils';
|
||||
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
|
||||
class OpenPgpKeyModel extends AbstractModel
|
||||
{
|
||||
class OpenPgpKeyModel extends AbstractModel {
|
||||
/**
|
||||
* @param {string} index
|
||||
* @param {string} guID
|
||||
|
|
@ -20,8 +18,7 @@ class OpenPgpKeyModel extends AbstractModel
|
|||
* @param {string} armor
|
||||
* @param {string} userID
|
||||
*/
|
||||
constructor(index, guID, ID, IDs, userIDs, emails, isPrivate, armor, userID)
|
||||
{
|
||||
constructor(index, guID, ID, IDs, userIDs, emails, isPrivate, armor, userID) {
|
||||
super('OpenPgpKeyModel');
|
||||
|
||||
this.index = index;
|
||||
|
|
@ -42,16 +39,12 @@ class OpenPgpKeyModel extends AbstractModel
|
|||
|
||||
getNativeKey() {
|
||||
let key = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
key = PgpStore.openpgp.key.readArmored(this.armor);
|
||||
if (key && !key.err && key.keys && key.keys[0])
|
||||
{
|
||||
if (key && !key.err && key.keys && key.keys[0]) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
|
||||
|
|
@ -64,11 +57,9 @@ class OpenPgpKeyModel extends AbstractModel
|
|||
}
|
||||
|
||||
select(pattern, property) {
|
||||
if (this[property])
|
||||
{
|
||||
if (this[property]) {
|
||||
const index = this[property].indexOf(pattern);
|
||||
if (-1 !== index)
|
||||
{
|
||||
if (-1 !== index) {
|
||||
this.user = this.users[index];
|
||||
this.email = this.emails[index];
|
||||
}
|
||||
|
|
@ -84,4 +75,4 @@ class OpenPgpKeyModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {OpenPgpKeyModel, OpenPgpKeyModel as default};
|
||||
export { OpenPgpKeyModel, OpenPgpKeyModel as default };
|
||||
|
|
|
|||
|
|
@ -1,19 +1,16 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {pString} from 'Common/Utils';
|
||||
import { pString } from 'Common/Utils';
|
||||
|
||||
import {AbstractModel} from 'Knoin/AbstractModel';
|
||||
import { AbstractModel } from 'Knoin/AbstractModel';
|
||||
|
||||
class TemplateModel extends AbstractModel
|
||||
{
|
||||
class TemplateModel extends AbstractModel {
|
||||
/**
|
||||
* @param {string} id
|
||||
* @param {string} name
|
||||
* @param {string} body
|
||||
*/
|
||||
constructor(id, name, body)
|
||||
{
|
||||
constructor(id, name, body) {
|
||||
super('TemplateModel');
|
||||
|
||||
this.id = id;
|
||||
|
|
@ -29,8 +26,7 @@ class TemplateModel extends AbstractModel
|
|||
*/
|
||||
parse(json) {
|
||||
let result = false;
|
||||
if (json && 'Object/Template' === json['@Object'])
|
||||
{
|
||||
if (json && 'Object/Template' === json['@Object']) {
|
||||
this.id = pString(json.ID);
|
||||
this.name = pString(json.Name);
|
||||
this.body = pString(json.Body);
|
||||
|
|
@ -43,4 +39,4 @@ class TemplateModel extends AbstractModel
|
|||
}
|
||||
}
|
||||
|
||||
export {TemplateModel, TemplateModel as default};
|
||||
export { TemplateModel, TemplateModel as default };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue