Folder list optimization

This commit is contained in:
RainLoop Team 2014-04-27 01:53:37 +04:00
parent 61a7a9c078
commit 547324f8d1
15 changed files with 113 additions and 99 deletions

View file

@ -794,6 +794,7 @@ RainLoopApp.prototype.folderListOptionsBuilder = function (aSystem, aList, aDisa
* @type {?FolderModel}
*/
oItem = null,
bSep = false,
sDeepPrefix = '\u00A0\u00A0\u00A0',
aResult = []
;
@ -820,41 +821,70 @@ RainLoopApp.prototype.folderListOptionsBuilder = function (aSystem, aList, aDisa
aResult.push({
'id': aHeaderLines[iIndex][0],
'name': aHeaderLines[iIndex][1],
'system': false,
'seporator': false,
'disabled': false
});
}
bSep = true;
for (iIndex = 0, iLen = aSystem.length; iIndex < iLen; iIndex++)
{
oItem = aSystem[iIndex];
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true)
{
if (bSep && 0 < aResult.length)
{
aResult.push({
'id': '---',
'name': '---',
'system': false,
'seporator': true,
'disabled': true
});
}
bSep = false;
aResult.push({
'id': oItem.fullNameRaw,
'system': true,
'name': fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name(),
'system': true,
'seporator': false,
'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false)
});
}
}
bSep = true;
for (iIndex = 0, iLen = aList.length; iIndex < iLen; iIndex++)
{
oItem = aList[iIndex];
if (!oItem.isGmailFolder && (oItem.subScribed() || !oItem.existen))
if (oItem.subScribed() || !oItem.existen)
{
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true)
{
if (Enums.FolderType.User === oItem.type() || !bSystem || (!oItem.isNamespaceFolder && 0 < oItem.subFolders().length))
if (Enums.FolderType.User === oItem.type() || !bSystem || 0 < oItem.subFolders().length)
{
if (bSep && 0 < aResult.length)
{
aResult.push({
'id': '---',
'name': '---',
'system': false,
'seporator': true,
'disabled': true
});
}
bSep = false;
aResult.push({
'id': oItem.fullNameRaw,
'system': false,
'name': (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) +
'name': (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) +
(fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name()),
'system': false,
'seporator': false,
'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) ||
(Enums.FolderType.User !== oItem.type()) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false)
});
}
@ -864,8 +894,7 @@ RainLoopApp.prototype.folderListOptionsBuilder = function (aSystem, aList, aDisa
if (oItem.subScribed() && 0 < oItem.subFolders().length)
{
aResult = aResult.concat(RL.folderListOptionsBuilder([], oItem.subFolders(), aDisabled, [],
oItem.isUnpaddigFolder ? iUnDeep + 1 : iUnDeep,
fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible));
iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible));
}
}

View file

@ -58,12 +58,6 @@ Consts.Defaults.ContactsSyncAjaxTimeout = 200000;
*/
Consts.Values.UnuseOptionValue = '__UNUSE__';
/**
* @const
* @type {string}
*/
Consts.Values.GmailFolderName = '[Gmail]';
/**
* @const
* @type {string}

View file

@ -12,16 +12,11 @@ function FolderModel()
this.delimiter = '';
this.namespace = '';
this.deep = 0;
this.interval = 0;
this.selectable = false;
this.existen = true;
this.isNamespaceFolder = false;
this.isGmailFolder = false;
this.isUnpaddigFolder = false;
this.interval = 0;
this.type = ko.observable(Enums.FolderType.User);
this.focused = ko.observable(false);
@ -70,7 +65,7 @@ FolderModel.prototype.initComputed = function ()
{
this.hasSubScribedSubfolders = ko.computed(function () {
return !!_.find(this.subFolders(), function (oFolder) {
return oFolder.subScribed();
return oFolder.subScribed() && !oFolder.isSystemFolder();
});
}, this);
@ -97,7 +92,8 @@ FolderModel.prototype.initComputed = function ()
bSubFolders = this.hasSubScribedSubfolders()
;
return this.isGmailFolder || (bSystem && this.isNamespaceFolder) || (bSystem && !bSubFolders);
return (bSystem && !bSubFolders) || (!this.selectable && !bSubFolders);
}, this);
this.selectableForFolderList = ko.computed(function () {
@ -292,10 +288,6 @@ FolderModel.prototype.namespace = '';
FolderModel.prototype.deep = 0;
FolderModel.prototype.interval = 0;
FolderModel.prototype.isNamespaceFolder = false;
FolderModel.prototype.isGmailFolder = false;
FolderModel.prototype.isUnpaddigFolder = false;
/**
* @return {string}
*/

View file

@ -585,17 +585,6 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
{
RL.cache().setFolderToCacheList(sFolderFullNameRaw, oCacheFolder);
RL.cache().setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw);
oCacheFolder.isGmailFolder = Consts.Values.GmailFolderName.toLowerCase() === sFolderFullNameRaw.toLowerCase();
if ('' !== sNamespace && sNamespace === oCacheFolder.fullNameRaw + oCacheFolder.delimiter)
{
oCacheFolder.isNamespaceFolder = true;
}
if (oCacheFolder.isNamespaceFolder || oCacheFolder.isGmailFolder)
{
oCacheFolder.isUnpaddigFolder = true;
}
}
}

View file

@ -655,7 +655,7 @@ MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage)
RL.remote().sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
oMessage.readReceipt(),
Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': oMessage.readReceipt()}));
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': RL.data().accountEmail()}));
oMessage.isReadReceipt(true);

View file

@ -43,7 +43,7 @@ function PopupsFolderCreateViewModel()
return RL.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback);
}, this);
// commands
this.createFolder = Utils.createCommand(this, function () {

View file

@ -2,7 +2,7 @@
"name": "RainLoop",
"title": "RainLoop Webmail",
"version": "1.6.5",
"release": "908",
"release": "909",
"description": "Simple, modern & fast web-based email client",
"homepage": "http://rainloop.net",
"main": "Gruntfile.js",

View file

@ -3588,9 +3588,16 @@ class Actions
$mFolderNameToCreate = \array_search($iType, $aMap);
if (!empty($mFolderNameToCreate))
{
if ($this->MailClient()->FolderCreate($mFolderNameToCreate, $sNamespace))
try
{
$bDoItAgain = true;
if ($this->MailClient()->FolderCreate($mFolderNameToCreate, $sNamespace))
{
$bDoItAgain = true;
}
}
catch (\Exception $oException)
{
$this->Logger()->WriteException($oException);
}
}
}

View file

@ -7,5 +7,5 @@
<i data-bind="css: collapsedCss()"></i>
<span class="name" data-bind="text: name"></span>
</a>
<div class="b-sub-folders" data-bind="template: { name: 'MailFolderListItem', foreach: subFolders }, css: { 'unpaddig-folder' : isUnpaddigFolder, 'collapsed': collapsed() }"></div>
<div class="b-sub-folders" data-bind="template: { name: 'MailFolderListItem', foreach: subFolders }, css: { 'collapsed': collapsed() }"></div>
</div>

View file

@ -16,9 +16,14 @@
<span class="caret"></span>
</a>
<ul class="dropdown-menu g-ui-menu" role="menu" aria-labelledby="move-dropdown-id" role="menu" data-bind="foreach: folderMenuForMove">
<li class="e-item" role="presentation" data-bind="css: { 'disabled': disabled }, click: function () { if (!disabled) $root.moveSelectedMessagesToFolder(id); }">
<a class="e-link menuitem" href="#" tabindex="-1" data-bind="text: name"></a>
</li>
<!-- ko if: seporator -->
<li class="divider" role="presentation" data-bind="visible: seporator"></li>
<!-- /ko -->
<!-- ko if: !seporator -->
<li class="e-item" role="presentation" data-bind="css: { 'disabled': disabled }, click: function () { if (!disabled) $root.moveSelectedMessagesToFolder(id); }">
<a class="e-link menuitem" href="#" tabindex="-1" data-bind="text: name"></a>
</li>
<!-- /ko -->
</ul>
</div>
<div class="btn-group">&nbsp;</div>

View file

@ -1,4 +1,4 @@
<tr class="folder-item" data-bind="css: { 'selectable': selectable, 'gmailFolder' : isGmailFolder, 'system': isSystemFolder }">
<tr class="folder-item" data-bind="css: { 'selectable': selectable, 'system': isSystemFolder }">
<td>
<span class="folder-padding" data-bind="css: 'deep-' + deep">&nbsp;</span>
<span class="folder-name" data-bind="text: name, visible: !edited(), css: { 'e-action': canBeEdited, 'can-be-edited': canBeEdited }, click: function (oFolder) { $root.folderForEdit(oFolder); }"></span>

View file

@ -290,12 +290,6 @@ Consts.Defaults.ContactsSyncAjaxTimeout = 200000;
*/
Consts.Values.UnuseOptionValue = '__UNUSE__';
/**
* @const
* @type {string}
*/
Consts.Values.GmailFolderName = '[Gmail]';
/**
* @const
* @type {string}

File diff suppressed because one or more lines are too long

View file

@ -294,12 +294,6 @@ Consts.Defaults.ContactsSyncAjaxTimeout = 200000;
*/
Consts.Values.UnuseOptionValue = '__UNUSE__';
/**
* @const
* @type {string}
*/
Consts.Values.GmailFolderName = '[Gmail]';
/**
* @const
* @type {string}
@ -7456,16 +7450,11 @@ function FolderModel()
this.delimiter = '';
this.namespace = '';
this.deep = 0;
this.interval = 0;
this.selectable = false;
this.existen = true;
this.isNamespaceFolder = false;
this.isGmailFolder = false;
this.isUnpaddigFolder = false;
this.interval = 0;
this.type = ko.observable(Enums.FolderType.User);
this.focused = ko.observable(false);
@ -7514,7 +7503,7 @@ FolderModel.prototype.initComputed = function ()
{
this.hasSubScribedSubfolders = ko.computed(function () {
return !!_.find(this.subFolders(), function (oFolder) {
return oFolder.subScribed();
return oFolder.subScribed() && !oFolder.isSystemFolder();
});
}, this);
@ -7541,7 +7530,8 @@ FolderModel.prototype.initComputed = function ()
bSubFolders = this.hasSubScribedSubfolders()
;
return this.isGmailFolder || (bSystem && this.isNamespaceFolder) || (bSystem && !bSubFolders);
return (bSystem && !bSubFolders) || (!this.selectable && !bSubFolders);
}, this);
this.selectableForFolderList = ko.computed(function () {
@ -7736,10 +7726,6 @@ FolderModel.prototype.namespace = '';
FolderModel.prototype.deep = 0;
FolderModel.prototype.interval = 0;
FolderModel.prototype.isNamespaceFolder = false;
FolderModel.prototype.isGmailFolder = false;
FolderModel.prototype.isUnpaddigFolder = false;
/**
* @return {string}
*/
@ -8011,7 +7997,7 @@ function PopupsFolderCreateViewModel()
return RL.folderListOptionsBuilder([], aList, [], aTop, null, fDisableCallback, fVisibleCallback, fRenameCallback);
}, this);
// commands
this.createFolder = Utils.createCommand(this, function () {
@ -13551,7 +13537,7 @@ MailBoxMessageViewViewModel.prototype.readReceipt = function (oMessage)
RL.remote().sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
oMessage.readReceipt(),
Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': oMessage.readReceipt()}));
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': RL.data().accountEmail()}));
oMessage.isReadReceipt(true);
@ -15675,17 +15661,6 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
{
RL.cache().setFolderToCacheList(sFolderFullNameRaw, oCacheFolder);
RL.cache().setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw);
oCacheFolder.isGmailFolder = Consts.Values.GmailFolderName.toLowerCase() === sFolderFullNameRaw.toLowerCase();
if ('' !== sNamespace && sNamespace === oCacheFolder.fullNameRaw + oCacheFolder.delimiter)
{
oCacheFolder.isNamespaceFolder = true;
}
if (oCacheFolder.isNamespaceFolder || oCacheFolder.isGmailFolder)
{
oCacheFolder.isUnpaddigFolder = true;
}
}
}
@ -19306,6 +19281,7 @@ RainLoopApp.prototype.folderListOptionsBuilder = function (aSystem, aList, aDisa
* @type {?FolderModel}
*/
oItem = null,
bSep = false,
sDeepPrefix = '\u00A0\u00A0\u00A0',
aResult = []
;
@ -19332,41 +19308,70 @@ RainLoopApp.prototype.folderListOptionsBuilder = function (aSystem, aList, aDisa
aResult.push({
'id': aHeaderLines[iIndex][0],
'name': aHeaderLines[iIndex][1],
'system': false,
'seporator': false,
'disabled': false
});
}
bSep = true;
for (iIndex = 0, iLen = aSystem.length; iIndex < iLen; iIndex++)
{
oItem = aSystem[iIndex];
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true)
{
if (bSep && 0 < aResult.length)
{
aResult.push({
'id': '---',
'name': '---',
'system': false,
'seporator': true,
'disabled': true
});
}
bSep = false;
aResult.push({
'id': oItem.fullNameRaw,
'system': true,
'name': fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name(),
'system': true,
'seporator': false,
'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false)
});
}
}
bSep = true;
for (iIndex = 0, iLen = aList.length; iIndex < iLen; iIndex++)
{
oItem = aList[iIndex];
if (!oItem.isGmailFolder && (oItem.subScribed() || !oItem.existen))
if (oItem.subScribed() || !oItem.existen)
{
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true)
{
if (Enums.FolderType.User === oItem.type() || !bSystem || (!oItem.isNamespaceFolder && 0 < oItem.subFolders().length))
if (Enums.FolderType.User === oItem.type() || !bSystem || 0 < oItem.subFolders().length)
{
if (bSep && 0 < aResult.length)
{
aResult.push({
'id': '---',
'name': '---',
'system': false,
'seporator': true,
'disabled': true
});
}
bSep = false;
aResult.push({
'id': oItem.fullNameRaw,
'system': false,
'name': (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) +
'name': (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) +
(fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name()),
'system': false,
'seporator': false,
'disabled': !oItem.selectable || -1 < Utils.inArray(oItem.fullNameRaw, aDisabled) ||
(Enums.FolderType.User !== oItem.type()) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false)
});
}
@ -19376,8 +19381,7 @@ RainLoopApp.prototype.folderListOptionsBuilder = function (aSystem, aList, aDisa
if (oItem.subScribed() && 0 < oItem.subFolders().length)
{
aResult = aResult.concat(RL.folderListOptionsBuilder([], oItem.subFolders(), aDisabled, [],
oItem.isUnpaddigFolder ? iUnDeep + 1 : iUnDeep,
fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible));
iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible));
}
}

File diff suppressed because one or more lines are too long