Small fixes

This commit is contained in:
RainLoop Team 2016-05-22 20:35:09 +03:00
parent fcfd54215a
commit aeec36de19
7 changed files with 123 additions and 129 deletions

View file

@ -1,123 +0,0 @@
(function () {
'use strict';
var
Utils = require('Common/Utils'),
EmailModel = require('Model/Email')
;
/**
* @constructor
*/
function MessageHelper() {}
/**
* @param {Array.<EmailModel>} aEmail
* @param {boolean=} bFriendlyView
* @param {boolean=} bWrapWithLink = false
* @return {string}
*/
MessageHelper.prototype.emailArrayToString = function (aEmail, bFriendlyView, bWrapWithLink)
{
var
aResult = [],
iIndex = 0,
iLen = 0
;
if (Utils.isNonEmptyArray(aEmail))
{
for (iIndex = 0, iLen = aEmail.length; iIndex < iLen; iIndex++)
{
aResult.push(aEmail[iIndex].toLine(bFriendlyView, bWrapWithLink));
}
}
return aResult.join(', ');
};
/**
* @param {Array.<EmailModel>} aEmails
* @return {string}
*/
MessageHelper.prototype.emailArrayToStringClear = function (aEmails)
{
var
aResult = [],
iIndex = 0,
iLen = 0
;
if (Utils.isNonEmptyArray(aEmails))
{
for (iIndex = 0, iLen = aEmails.length; iIndex < iLen; iIndex++)
{
if (aEmails[iIndex] && aEmails[iIndex].email && '' !== aEmails[iIndex].name)
{
aResult.push(aEmails[iIndex].email);
}
}
}
return aResult.join(', ');
};
/**
* @param {?Array} aJson
* @return {Array.<EmailModel>}
*/
MessageHelper.prototype.emailArrayFromJson = function (aJson)
{
var
iIndex = 0,
iLen = 0,
oEmailModel = null,
aResult = []
;
if (Utils.isNonEmptyArray(aJson))
{
for (iIndex = 0, iLen = aJson.length; iIndex < iLen; iIndex++)
{
oEmailModel = EmailModel.newInstanceFromJson(aJson[iIndex]);
if (oEmailModel)
{
aResult.push(oEmailModel);
}
}
}
return aResult;
};
/**
* @param {Array.<EmailModel>} aInputEmails
* @param {Object} oUnic
* @param {Array} aLocalEmails
*/
MessageHelper.prototype.replyHelper = function (aInputEmails, oUnic, aLocalEmails)
{
if (aInputEmails && 0 < aInputEmails.length)
{
var
iIndex = 0,
iLen = aInputEmails.length
;
for (; iIndex < iLen; iIndex++)
{
if (Utils.isUnd(oUnic[aInputEmails[iIndex].email]))
{
oUnic[aInputEmails[iIndex].email] = true;
aLocalEmails.push(aInputEmails[iIndex]);
}
}
}
};
module.exports = new MessageHelper();
}());

112
dev/Helper/Message.jsx Normal file
View file

@ -0,0 +1,112 @@
import Utils from 'Common/Utils';
import EmailModel from 'Model/Email';
class MessageHelper
{
constructor() {}
/**
* @param {Array.<EmailModel>} emails
* @param {boolean=} friendlyView = false
* @param {boolean=} wrapWithLink = false
* @return {string}
*/
emailArrayToString(emails, friendlyView = false, wrapWithLink = false) {
let
result = [],
index = 0,
len = 0
;
if (Utils.isNonEmptyArray(emails))
{
for (index = 0, len = emails.length; index < len; index++)
{
result.push(emails[index].toLine(friendlyView, wrapWithLink));
}
}
return result.join(', ');
}
/**
* @param {Array.<EmailModel>} emails
* @return {string}
*/
emailArrayToStringClear(emails) {
let
result = [],
index = 0,
len = 0
;
if (Utils.isNonEmptyArray(emails))
{
for (index = 0, len = emails.length; index < len; index++)
{
if (emails[index] && emails[index].email && '' !== emails[index].name)
{
result.push(emails[index].email);
}
}
}
return result.join(', ');
}
/**
* @param {?Array} json
* @return {Array.<EmailModel>}
*/
emailArrayFromJson(json) {
let
index = 0,
len = 0,
email = null,
result = []
;
if (Utils.isNonEmptyArray(json))
{
for (index = 0, len = json.length; index < len; index++)
{
email = EmailModel.newInstanceFromJson(json[index]);
if (email)
{
result.push(email);
}
}
}
return result;
}
/**
* @param {Array.<EmailModel>} inputEmails
* @param {Object} unic
* @param {Array} localEmails
*/
replyHelper(inputEmails, unic, localEmails) {
if (inputEmails && 0 < inputEmails.length)
{
let index = 0;
const len = inputEmails.length;
for (; index < len; index++)
{
if (Utils.isUnd(unic[inputEmails[index].email]))
{
unic[inputEmails[index].email] = true;
localEmails.push(inputEmails[index]);
}
}
}
}
}
export default new MessageHelper();

View file

@ -16,7 +16,7 @@
AttachmentModel = require('Model/Attachment'),
MessageHelper = require('Helper/Message'),
MessageHelper = require('Helper/Message').default,
AbstractModel = require('Knoin/AbstractModel')
;

View file

@ -9,7 +9,7 @@
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
// MessageHelper = require('Helper/Message'),
// MessageHelper = require('Helper/Message').default,
MessageSimpleModel = require('Model/MessageSimple')
;

View file

@ -9,7 +9,7 @@
Utils = require('Common/Utils'),
MessageHelper = require('Helper/Message'),
MessageHelper = require('Helper/Message').default,
AbstractModel = require('Knoin/AbstractModel')
;

View file

@ -28,7 +28,7 @@
Remote = require('Remote/User/Ajax'),
MessageModel = require('Model/Message'),
MessageHelper = require('Helper/Message')
MessageHelper = require('Helper/Message').default
;
/**

View file

@ -995,8 +995,13 @@ class ImapClient extends \MailSo\Net\NetClient
*/
public function FolderUnSelect()
{
return $this->IsSelected() && $this->IsSupported('UNSELECT') ?
$this->SendRequestWithCheck('UNSELECT') : $this;
if ($this->IsSelected() && $this->IsSupported('UNSELECT'))
{
$this->SendRequestWithCheck('UNSELECT');
$this->bIsSelected = false;
}
return $this;
}
/**