PromisesUserPopulator.prototype.foldersList = function(oData) { if (oData && 'Collection/FolderCollection' === oData['@Object'] && oData['@Collection'] && Utils.isArray(oData['@Collection'])) { var iLimit = Utils.pInt(Settings.appSettingsGet('folderSpecLimit')), iC = Utils.pInt(oData.CountRec); iLimit = 100 < iLimit ? 100 : (10 > iLimit ? 10 : iLimit); FolderStore.displaySpecSetting(0 >= iC || iLimit < iC); FolderStore.folderList(this.folderResponseParseRec( Utils.isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'])); } };
foldersList(oData) { if (oData && 'Collection/FolderCollection' === oData['@Object'] && oData['@Collection'] && isArray(oData['@Collection'])) { const expandedFolders = Local.get(ClientSideKeyName.ExpandedFolders), cnt = pInt(oData.CountRec); let limit = pInt(Settings.appSettingsGet('folderSpecLimit')); limit = 100 < limit ? 100 : (10 > limit ? 10 : limit); FolderStore.displaySpecSetting(0 >= cnt || limit < cnt); FolderStore.folderList(this.folderResponseParseRec( isUnd(oData.Namespace) ? '' : oData.Namespace, oData['@Collection'], expandedFolders)); // @todo optimization required } }
PromisesUserPopulator.prototype.folderResponseParseRec = function (sNamespace, aFolders) { var self = this, iIndex = 0, iLen = 0, oFolder = null, oCacheFolder = null, sFolderFullNameRaw = '', aSubFolders = [], aList = [] ; for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++) { oFolder = aFolders[iIndex]; if (oFolder) { sFolderFullNameRaw = oFolder.FullNameRaw; oCacheFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw); if (!oCacheFolder) { oCacheFolder = FolderModel.newInstanceFromJson(oFolder); if (oCacheFolder) { Cache.setFolderToCacheList(sFolderFullNameRaw, oCacheFolder); Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw, oCacheFolder); } } if (oCacheFolder) { if (!FolderStore.displaySpecSetting()) { oCacheFolder.checkable(true); } else { oCacheFolder.checkable(!!oFolder.Checkable); } oCacheFolder.collapsed(!self.isFolderExpanded(oCacheFolder.fullNameHash)); if (oFolder.Extended) { if (oFolder.Extended.Hash) { Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash); } if (Utils.isNormal(oFolder.Extended.MessageCount)) { oCacheFolder.messageCountAll(oFolder.Extended.MessageCount); } if (Utils.isNormal(oFolder.Extended.MessageUnseenCount)) { oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount); } } aSubFolders = oFolder['SubFolders']; if (aSubFolders && 'Collection/FolderCollection' === aSubFolders['@Object'] && aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection'])) { oCacheFolder.subFolders( this.folderResponseParseRec(sNamespace, aSubFolders['@Collection'])); } aList.push(oCacheFolder); } } } return aList; };
/** * @param {string} sNamespace * @param {Array} aFolders * @param {Array?} expandedFolders * @returns {Array} */ folderResponseParseRec(sNamespace, aFolders, expandedFolders) { const bDisplaySpecSetting = FolderStore.displaySpecSetting(), aList = []; _.each(aFolders, (oFolder) => { if (oFolder) { let oCacheFolder = Cache.getFolderFromCacheList(oFolder.FullNameRaw); if (!oCacheFolder) { oCacheFolder = FolderModel.newInstanceFromJson(oFolder); if (oCacheFolder) { Cache.setFolderToCacheList(oFolder.FullNameRaw, oCacheFolder); Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, oFolder.FullNameRaw, oCacheFolder); } } if (oCacheFolder) { if (bDisplaySpecSetting) { oCacheFolder.checkable(!!oFolder.Checkable); } else { oCacheFolder.checkable(true); } oCacheFolder.collapsed(!this.isFolderExpanded(oCacheFolder.fullNameHash, expandedFolders)); if (oFolder.Extended) { if (oFolder.Extended.Hash) { Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash); } if (isNormal(oFolder.Extended.MessageCount)) { oCacheFolder.messageCountAll(oFolder.Extended.MessageCount); } if (isNormal(oFolder.Extended.MessageUnseenCount)) { oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount); } } if (oFolder.SubFolders && 'Collection/FolderCollection' === oFolder.SubFolders['@Object'] && oFolder.SubFolders['@Collection'] && isArray(oFolder.SubFolders['@Collection'])) { oCacheFolder.subFolders( this.folderResponseParseRec(sNamespace, oFolder.SubFolders['@Collection'], expandedFolders)); } aList.push(oCacheFolder); } } }); return aList; }