More fixes for scrutinizer-ci

This commit is contained in:
RainLoop Team 2016-08-09 22:52:30 +03:00
parent c7e97b78d6
commit 59b32241bf
16 changed files with 116 additions and 191 deletions

View file

@ -56,9 +56,7 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut,
var self = this;
return new Promise(function(resolve, reject) {
var
oH = null,
iStart = Utils.microtime();
var iStart = Utils.microtime();
iTimeOut = Utils.isNormal(iTimeOut) ? iTimeOut : Consts.DEFAULT_AJAX_TIMEOUT;
sAdditionalGetString = Utils.isUnd(sAdditionalGetString) ? '' : Utils.pString(sAdditionalGetString);
@ -72,7 +70,7 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut,
self.setTrigger(fTrigger, true);
oH = $.ajax({
var oH = $.ajax({
type: bPost ? 'POST' : 'GET',
url: Links.ajax(sAdditionalGetString),
async: true,
@ -81,10 +79,10 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut,
timeout: iTimeOut,
global: true
}).always(function(oData, sTextStatus) {
var
bCached = false,
oErrorData = null,
sType = Enums.StorageResultType.Error;
oErrorData = null;
if (oData && oData.Time)
{
@ -92,6 +90,7 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut,
}
// backward capability
var sType = Enums.StorageResultType.Error;
switch (true)
{
case 'success' === sTextStatus && oData && oData.Result && sAction === oData.Action:
@ -100,7 +99,9 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut,
case 'abort' === sTextStatus && (!oData || !oData.__aborted__):
sType = Enums.StorageResultType.Abort;
break;
// no default
default:
sType = Enums.StorageResultType.Error;
break;
}
Plugins.runHook('ajax-default-response', [sAction,

View file

@ -57,30 +57,20 @@ PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aF
{
var
self = this,
iIndex = 0,
iLen = 0,
oFolder = null,
oCacheFolder = null,
bDisplaySpecSetting = FolderStore.displaySpecSetting(),
sFolderFullNameRaw = '',
aSubFolders = [],
aList = [];
for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++)
{
oFolder = aFolders[iIndex];
_.each(aFolders, function(oFolder) {
if (oFolder)
{
sFolderFullNameRaw = oFolder.FullNameRaw;
oCacheFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
var oCacheFolder = Cache.getFolderFromCacheList(oFolder.FullNameRaw);
if (!oCacheFolder)
{
oCacheFolder = FolderModel.newInstanceFromJson(oFolder);
if (oCacheFolder)
{
Cache.setFolderToCacheList(sFolderFullNameRaw, oCacheFolder);
Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw, oCacheFolder);
Cache.setFolderToCacheList(oFolder.FullNameRaw, oCacheFolder);
Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, oFolder.FullNameRaw, oCacheFolder);
}
}
@ -115,18 +105,17 @@ PromisesUserPopulator.prototype.folderResponseParseRec = function(sNamespace, aF
}
}
aSubFolders = oFolder.SubFolders;
if (aSubFolders && 'Collection/FolderCollection' === aSubFolders['@Object'] &&
aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection']))
if (oFolder.SubFolders && 'Collection/FolderCollection' === oFolder.SubFolders['@Object'] &&
oFolder.SubFolders['@Collection'] && Utils.isArray(oFolder.SubFolders['@Collection']))
{
oCacheFolder.subFolders(
this.folderResponseParseRec(sNamespace, aSubFolders['@Collection'], expandedFolders));
self.folderResponseParseRec(sNamespace, oFolder.SubFolders['@Collection'], expandedFolders));
}
aList.push(oCacheFolder);
}
}
}
});
return aList;
};
@ -137,7 +126,6 @@ PromisesUserPopulator.prototype.foldersList = function(oData)
oData['@Collection'] && Utils.isArray(oData['@Collection']))
{
var
folderList = [],
expandedFolders = Local.get(Enums.ClientSideKeyName.ExpandedFolders),
iLimit = Utils.pInt(Settings.appSettingsGet('folderSpecLimit')),
iC = Utils.pInt(oData.CountRec);
@ -145,8 +133,9 @@ PromisesUserPopulator.prototype.foldersList = function(oData)
iLimit = 100 < iLimit ? 100 : (10 > iLimit ? 10 : iLimit);
FolderStore.displaySpecSetting(0 >= iC || iLimit < iC);
folderList = this.folderResponseParseRec(Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders);
FolderStore.folderList(folderList); // @todo optimization required
FolderStore.folderList(this.folderResponseParseRec(
Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders)); // @todo optimization required
}
};