mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Determine the number of unread messages in all folders.
This commit is contained in:
parent
975947a948
commit
b7c4aad3db
|
@ -267,6 +267,7 @@ RainLoopApp.prototype.folderInformation = function (sFolder, aList)
|
|||
if (oData && oData.Result && oData.Result.Hash && oData.Result.Folder)
|
||||
{
|
||||
var
|
||||
iUtc = moment().unix(),
|
||||
sHash = RL.cache().getFolderHash(oData.Result.Folder),
|
||||
oFolder = RL.cache().getFolderFromCacheList(oData.Result.Folder),
|
||||
bCheck = false,
|
||||
|
@ -278,6 +279,8 @@ RainLoopApp.prototype.folderInformation = function (sFolder, aList)
|
|||
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
|
||||
if (oData.Result.Hash)
|
||||
{
|
||||
RL.cache().setFolderHash(oData.Result.Folder, oData.Result.Hash);
|
||||
|
@ -354,6 +357,94 @@ RainLoopApp.prototype.folderInformation = function (sFolder, aList)
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean=} bBoot = false
|
||||
*/
|
||||
RainLoopApp.prototype.folderInformationMultiply = function (bBoot)
|
||||
{
|
||||
bBoot = Utils.isUnd(bBoot) ? false : !!bBoot;
|
||||
|
||||
var
|
||||
iUtc = moment().unix(),
|
||||
aFolders = RL.data().getNextFolderNames(bBoot)
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(aFolders))
|
||||
{
|
||||
this.remote().folderInformationMultiply(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success === sResult)
|
||||
{
|
||||
if (oData && oData.Result && oData.Result.List && Utils.isNonEmptyArray(oData.Result.List))
|
||||
{
|
||||
_.each(oData.Result.List, function (oItem) {
|
||||
|
||||
var
|
||||
aList = [],
|
||||
sHash = RL.cache().getFolderHash(oItem.Folder),
|
||||
oFolder = RL.cache().getFolderFromCacheList(oItem.Folder),
|
||||
bUnreadCountChange = false
|
||||
;
|
||||
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
|
||||
if (oItem.Hash)
|
||||
{
|
||||
RL.cache().setFolderHash(oItem.Folder, oItem.Hash);
|
||||
}
|
||||
|
||||
if (Utils.isNormal(oItem.MessageCount))
|
||||
{
|
||||
oFolder.messageCountAll(oItem.MessageCount);
|
||||
}
|
||||
|
||||
if (Utils.isNormal(oItem.MessageUnseenCount))
|
||||
{
|
||||
if (Utils.pInt(oFolder.messageCountUnread()) !== Utils.pInt(oItem.MessageUnseenCount))
|
||||
{
|
||||
bUnreadCountChange = true;
|
||||
}
|
||||
|
||||
oFolder.messageCountUnread(oItem.MessageUnseenCount);
|
||||
}
|
||||
|
||||
if (bUnreadCountChange)
|
||||
{
|
||||
RL.cache().clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw);
|
||||
}
|
||||
|
||||
if (oItem.Hash !== sHash || '' === sHash)
|
||||
{
|
||||
if (oFolder.fullNameRaw === RL.data().currentFolderFullNameRaw())
|
||||
{
|
||||
RL.reloadMessageList();
|
||||
}
|
||||
}
|
||||
else if (bUnreadCountChange)
|
||||
{
|
||||
if (oFolder.fullNameRaw === RL.data().currentFolderFullNameRaw())
|
||||
{
|
||||
aList = RL.data().messageList();
|
||||
if (Utils.isNonEmptyArray(aList))
|
||||
{
|
||||
RL.folderInformation(oFolder.fullNameRaw, aList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (bBoot)
|
||||
{
|
||||
RL.folderInformationMultiply(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, aFolders);
|
||||
}
|
||||
};
|
||||
|
||||
RainLoopApp.prototype.setMessageSeen = function (oMessage)
|
||||
{
|
||||
if (oMessage.unseen())
|
||||
|
@ -702,6 +793,30 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
RL.socialUsers(true);
|
||||
}
|
||||
|
||||
RL.sub('interval.2m', function () {
|
||||
RL.folderInformation('INBOX');
|
||||
});
|
||||
|
||||
RL.sub('interval.2m', function () {
|
||||
var sF = RL.data().currentFolderFullNameRaw();
|
||||
if ('INBOX' !== sF)
|
||||
{
|
||||
RL.folderInformation(sF);
|
||||
}
|
||||
});
|
||||
|
||||
RL.sub('interval.3m', function () {
|
||||
RL.folderInformationMultiply();
|
||||
});
|
||||
|
||||
RL.sub('interval.5m', function () {
|
||||
RL.quota();
|
||||
});
|
||||
|
||||
_.delay(function () {
|
||||
RL.folderInformationMultiply(true);
|
||||
}, 500);
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
RL.emailsPicsHashes();
|
||||
|
@ -712,15 +827,9 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
RL.cache().setServicesData(oData.Result);
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
RL.sub('interval.5m', function () {
|
||||
RL.quota();
|
||||
});
|
||||
}, 2000);
|
||||
|
||||
RL.sub('interval.2m', function () {
|
||||
RL.folderInformation('INBOX');
|
||||
});
|
||||
|
||||
Plugins.runHook('rl-start-user-screens');
|
||||
}
|
||||
|
|
|
@ -199,64 +199,6 @@ EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink, bEncodeHtm
|
|||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
EmailModel.prototype.select2Result = function ()
|
||||
{
|
||||
var
|
||||
sResult = '',
|
||||
sImg = RL.cache().getUserPic(this.email)
|
||||
;
|
||||
|
||||
if ('' !== sImg)
|
||||
{
|
||||
sResult += '<img class="select2-user-pic pull-left" src="' + Utils.encodeHtml(sImg) + '" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += '<img class="select2-user-pic pull-left" src="' + RL.link().emptyContactPic() + '" />';
|
||||
}
|
||||
|
||||
if (Enums.EmailType.Facebook === this.type())
|
||||
{
|
||||
sResult += '' + (0 < this.name.length ? this.name : this.email);
|
||||
sResult += '<i class="icon-facebook pull-right select2-icon-result" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += '' + (0 < this.name.length ? this.email + ' <span class="select2-subname">(' + this.name + ')</span>' : this.email);
|
||||
}
|
||||
|
||||
return sResult + '';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oContainer
|
||||
* @return {string|null}
|
||||
*/
|
||||
EmailModel.prototype.select2Selection = function (oContainer)
|
||||
{
|
||||
var sResult = '';
|
||||
if (Enums.EmailType.Facebook === this.type())
|
||||
{
|
||||
sResult = 0 < this.name.length ? this.name : this.email;
|
||||
if ('' !== sResult)
|
||||
{
|
||||
$('<pan>').text(sResult).appendTo(oContainer);
|
||||
oContainer.append('<i class="icon-facebook select2-icon"></i>');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} $sEmailAddress
|
||||
* @return {boolean}
|
||||
|
|
|
@ -20,6 +20,8 @@ function FolderModel()
|
|||
this.isGmailFolder = false;
|
||||
this.isUnpaddigFolder = false;
|
||||
|
||||
this.interval = 0;
|
||||
|
||||
this.type = ko.observable(Enums.FolderType.User);
|
||||
|
||||
this.selected = ko.observable(false);
|
||||
|
@ -143,10 +145,21 @@ FolderModel.prototype.initComputed = function ()
|
|||
RL.data().foldersInboxUnreadCount(iUnread);
|
||||
}
|
||||
|
||||
// return 0 < iUnread ? '' + iUnread : '';
|
||||
// return 0 < iUnread && 'INBOX' === this.fullNameRaw ? '' + iUnread : '';
|
||||
return 0 < iUnread && (Enums.FolderType.Inbox === iType || Enums.FolderType.Spam === iType) ? '' + iUnread :
|
||||
(0 < iCount && Enums.FolderType.Draft === iType ? '' + iCount : '');
|
||||
if (0 < iCount)
|
||||
{
|
||||
if (Enums.FolderType.Draft === iType)
|
||||
{
|
||||
return '' + iCount;
|
||||
}
|
||||
else if (0 < iUnread && Enums.FolderType.Trash !== iType && Enums.FolderType.SentItems !== iType)
|
||||
{
|
||||
return '' + iUnread;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
// return 0 < iUnread && (Enums.FolderType.Inbox === iType || Enums.FolderType.Spam === iType) ? '' + iUnread :
|
||||
// (0 < iCount && Enums.FolderType.Draft === iType ? '' + iCount : '');
|
||||
}, this);
|
||||
|
||||
this.canBeDeleted = ko.computed(function () {
|
||||
|
@ -261,6 +274,7 @@ FolderModel.prototype.fullNameHash = '';
|
|||
FolderModel.prototype.delimiter = '';
|
||||
FolderModel.prototype.namespace = '';
|
||||
FolderModel.prototype.deep = 0;
|
||||
FolderModel.prototype.interval = 0;
|
||||
|
||||
FolderModel.prototype.isNamespaceFolder = false;
|
||||
FolderModel.prototype.isGmailFolder = false;
|
||||
|
|
|
@ -90,22 +90,6 @@ MailBoxScreen.prototype.onStart = function ()
|
|||
}
|
||||
}, 1000);
|
||||
|
||||
_.delay(function () {
|
||||
var sFolder = RL.data().spamFolder();
|
||||
if (sFolder !== oData.currentFolderFullNameRaw() && '' !== sFolder)
|
||||
{
|
||||
RL.folderInformation(sFolder);
|
||||
}
|
||||
}, 1500);
|
||||
|
||||
_.delay(function () {
|
||||
var sFolder = RL.data().draftFolder();
|
||||
if (sFolder !== oData.currentFolderFullNameRaw() && '' !== sFolder)
|
||||
{
|
||||
RL.folderInformation(sFolder);
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
_.delay(function () {
|
||||
RL.quota();
|
||||
}, 5000);
|
||||
|
|
|
@ -269,6 +269,17 @@ WebMailAjaxRemoteStorage.prototype.folderInformation = function (fCallback, sFol
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Array} aFolders
|
||||
*/
|
||||
WebMailAjaxRemoteStorage.prototype.folderInformationMultiply = function (fCallback, aFolders)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'FolderInformationMultiply', {
|
||||
'Folders': aFolders
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
|
|
|
@ -650,6 +650,67 @@ WebMailDataStorage.prototype.hideMessageBodies = function ()
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean=} bBoot = false
|
||||
* @returns {Array}
|
||||
*/
|
||||
WebMailDataStorage.prototype.getNextFolderNames = function (bBoot)
|
||||
{
|
||||
bBoot = Utils.isUnd(bBoot) ? false : !!bBoot;
|
||||
|
||||
var
|
||||
aResult = [],
|
||||
iLimit = 10,
|
||||
iUtc = moment().unix(),
|
||||
iTimeout = iUtc - 60 * 5,
|
||||
aTimeouts = [],
|
||||
fSearchFunction = function (aList) {
|
||||
_.each(aList, function (oFolder) {
|
||||
if (oFolder && 'INBOX' !== oFolder.fullNameRaw &&
|
||||
oFolder.selectable && oFolder.existen &&
|
||||
iTimeout > oFolder.interval &&
|
||||
(!bBoot || oFolder.subScribed()))
|
||||
{
|
||||
aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]);
|
||||
}
|
||||
|
||||
if (oFolder && 0 < oFolder.subFolders().length)
|
||||
{
|
||||
fSearchFunction(oFolder.subFolders());
|
||||
}
|
||||
});
|
||||
}
|
||||
;
|
||||
|
||||
fSearchFunction(this.folderList());
|
||||
|
||||
aTimeouts.sort(function(a, b) {
|
||||
if (a[0] < b[0])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (a[0] > b[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
_.find(aTimeouts, function (aItem) {
|
||||
var oFolder = RL.cache().getFolderFromCacheList(aItem[1]);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
aResult.push(aItem[1]);
|
||||
}
|
||||
|
||||
return iLimit <= aResult.length;
|
||||
});
|
||||
|
||||
return _.uniq(aResult);
|
||||
};
|
||||
|
||||
WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
||||
{
|
||||
var
|
||||
|
@ -777,6 +838,7 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
|
|||
iCount = 0,
|
||||
iOffset = 0,
|
||||
aList = [],
|
||||
iUtc = moment().unix(),
|
||||
aStaticList = oRainLoopData.staticMessageList,
|
||||
oJsonMessage = null,
|
||||
oMessage = null,
|
||||
|
@ -798,6 +860,8 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
|
|||
|
||||
if (oFolder && !bCached)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
|
||||
RL.cache().setFolderHash(oData.Result.Folder, oData.Result.FolderHash);
|
||||
|
||||
if (Utils.isNormal(oData.Result.MessageCount))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "RainLoop",
|
||||
"title": "RainLoop Webmail",
|
||||
"version": "1.5.1",
|
||||
"release": "547",
|
||||
"release": "549",
|
||||
"description": "Simple, modern & fast web-based email client",
|
||||
"homepage": "http://rainloop.net",
|
||||
"main": "Gruntfile.js",
|
||||
|
|
|
@ -3417,7 +3417,7 @@ class Actions
|
|||
$aFlagsFilteredUids = array();
|
||||
if (0 < strlen($sFlagsUids))
|
||||
{
|
||||
$aFlagsUids = explode(',', (string) $this->GetActionParam('FlagsUids', ''));
|
||||
$aFlagsUids = explode(',', $sFlagsUids);
|
||||
$aFlagsFilteredUids = array_filter($aFlagsUids, function (&$sUid) {
|
||||
$sUid = (int) trim($sUid);
|
||||
return 0 < (int) trim($sUid);
|
||||
|
@ -3431,6 +3431,8 @@ class Actions
|
|||
try
|
||||
{
|
||||
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder, $sPrevUidNext, $aFlagsFilteredUids);
|
||||
if (\is_array($aInboxInformation) && isset($aInboxInformation['Flags']) && \is_array($aInboxInformation['Flags']))
|
||||
{
|
||||
foreach ($aInboxInformation['Flags'] as $iUid => $aFlags)
|
||||
{
|
||||
$aLowerFlags = array_map('strtolower', $aFlags);
|
||||
|
@ -3442,6 +3444,7 @@ class Actions
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::MailServerError, $oException);
|
||||
|
@ -3455,6 +3458,47 @@ class Actions
|
|||
return $this->DefaultResponse(__FUNCTION__, $aInboxInformation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\Exception
|
||||
*/
|
||||
public function DoFolderInformationMultiply()
|
||||
{
|
||||
$aResult = array(
|
||||
'List' => array(),
|
||||
'Version' => APP_VERSION
|
||||
);
|
||||
|
||||
$aFolders = $this->GetActionParam('Folders', null);
|
||||
if (\is_array($aFolders))
|
||||
{
|
||||
$this->initMailClientConnection();
|
||||
|
||||
$aFolders = \array_unique($aFolders);
|
||||
foreach ($aFolders as $sFolder)
|
||||
{
|
||||
if (0 < \strlen(\trim($sFolder)) && 'INBOX' !== \strtoupper($sFolder))
|
||||
{
|
||||
try
|
||||
{
|
||||
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder);
|
||||
if (\is_array($aInboxInformation) && isset($aInboxInformation['Folder']))
|
||||
{
|
||||
$aResult['List'][] = $aInboxInformation;
|
||||
}
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
$this->Logger()->WriteException($oException);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->DefaultResponse(__FUNCTION__, $aResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
|
|
|
@ -60,11 +60,18 @@
|
|||
</div>
|
||||
<div class="control-group" data-bind="visible: subscriptionEnabled() && !licensingProcess()">
|
||||
<div class="controls">
|
||||
<button class="btn" data-bind="click: showActivationForm">
|
||||
<a class="btn" data-bind="click: showActivationForm">
|
||||
<i class="icon-heart-empty"></i>
|
||||
|
||||
Activate Subscription Key
|
||||
</button>
|
||||
</a>
|
||||
|
||||
|
||||
<a class="btn" href="http://rainloop.net/purchase/" target="_black">
|
||||
<i class="icon-purchase"></i>
|
||||
|
||||
Purchase
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
{{INCLUDE/MenuDropdownTop/PLACE}}
|
||||
<li class="e-item" data-bind="visible: facebookLoginEnabled">
|
||||
<a class="e-link" data-bind="command: facebookCommand">
|
||||
<i class="icon-facebook-2"></i>
|
||||
<i class="icon-facebook-alt"></i>
|
||||
|
||||
<span class="i18n" data-i18n-text="LOGIN/TITLE_SIGN_IN_FACEBOOK"></span>
|
||||
</a>
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
droppableOver: function (oEvent, oUi) { $root.messagesDropOver($data, oUi); },
|
||||
droppableOut: function (oEvent, oUi) { $root.messagesDropOut($data, oUi); },
|
||||
css: { 'selected': selected() && !isSystemFolder(), 'selectable': selectableForFolderList, 'hidden' : hidden, 'print-count': 0 < printableUnreadCount().length, 'system': isSystemFolder, 'anim-action-class': actionBlink }">
|
||||
<span class="badge pull-right count" data-bind="text: printableUnreadCount"></span>
|
||||
<i data-bind="css: collapsedCss()"></i>
|
||||
<span class="name" data-bind="text: name"></span><!-- <span class="badge pull-right count" data-bind="text: printableUnreadCount"></span> -->
|
||||
<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>
|
|
@ -42,11 +42,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="btn" href="http://rainloop.net/purchase/" target="_black">
|
||||
<i class="icon-purchase"></i>
|
||||
|
||||
Purchase
|
||||
</a>
|
||||
<a class="btn buttonActivate" data-bind="visible: !activationSuccessed(), command: activateCommand">
|
||||
<i class="icon-key" data-bind="css: {'icon-key': !activateProcess(), 'icon-spinner animated': activateProcess()}" ></i>
|
||||
|
||||
|
|
|
@ -4173,64 +4173,6 @@ EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink, bEncodeHtm
|
|||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
EmailModel.prototype.select2Result = function ()
|
||||
{
|
||||
var
|
||||
sResult = '',
|
||||
sImg = RL.cache().getUserPic(this.email)
|
||||
;
|
||||
|
||||
if ('' !== sImg)
|
||||
{
|
||||
sResult += '<img class="select2-user-pic pull-left" src="' + Utils.encodeHtml(sImg) + '" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += '<img class="select2-user-pic pull-left" src="' + RL.link().emptyContactPic() + '" />';
|
||||
}
|
||||
|
||||
if (Enums.EmailType.Facebook === this.type())
|
||||
{
|
||||
sResult += '' + (0 < this.name.length ? this.name : this.email);
|
||||
sResult += '<i class="icon-facebook pull-right select2-icon-result" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += '' + (0 < this.name.length ? this.email + ' <span class="select2-subname">(' + this.name + ')</span>' : this.email);
|
||||
}
|
||||
|
||||
return sResult + '';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oContainer
|
||||
* @return {string|null}
|
||||
*/
|
||||
EmailModel.prototype.select2Selection = function (oContainer)
|
||||
{
|
||||
var sResult = '';
|
||||
if (Enums.EmailType.Facebook === this.type())
|
||||
{
|
||||
sResult = 0 < this.name.length ? this.name : this.email;
|
||||
if ('' !== sResult)
|
||||
{
|
||||
$('<pan>').text(sResult).appendTo(oContainer);
|
||||
oContainer.append('<i class="icon-facebook select2-icon"></i>');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} $sEmailAddress
|
||||
* @return {boolean}
|
||||
|
|
4
rainloop/v/0.0.0/static/js/admin.min.js
vendored
4
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -5603,64 +5603,6 @@ EmailModel.prototype.toLine = function (bFriendlyView, bWrapWithLink, bEncodeHtm
|
|||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
EmailModel.prototype.select2Result = function ()
|
||||
{
|
||||
var
|
||||
sResult = '',
|
||||
sImg = RL.cache().getUserPic(this.email)
|
||||
;
|
||||
|
||||
if ('' !== sImg)
|
||||
{
|
||||
sResult += '<img class="select2-user-pic pull-left" src="' + Utils.encodeHtml(sImg) + '" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += '<img class="select2-user-pic pull-left" src="' + RL.link().emptyContactPic() + '" />';
|
||||
}
|
||||
|
||||
if (Enums.EmailType.Facebook === this.type())
|
||||
{
|
||||
sResult += '' + (0 < this.name.length ? this.name : this.email);
|
||||
sResult += '<i class="icon-facebook pull-right select2-icon-result" />';
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult += '' + (0 < this.name.length ? this.email + ' <span class="select2-subname">(' + this.name + ')</span>' : this.email);
|
||||
}
|
||||
|
||||
return sResult + '';
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oContainer
|
||||
* @return {string|null}
|
||||
*/
|
||||
EmailModel.prototype.select2Selection = function (oContainer)
|
||||
{
|
||||
var sResult = '';
|
||||
if (Enums.EmailType.Facebook === this.type())
|
||||
{
|
||||
sResult = 0 < this.name.length ? this.name : this.email;
|
||||
if ('' !== sResult)
|
||||
{
|
||||
$('<pan>').text(sResult).appendTo(oContainer);
|
||||
oContainer.append('<i class="icon-facebook select2-icon"></i>');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sResult = 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} $sEmailAddress
|
||||
* @return {boolean}
|
||||
|
@ -7154,6 +7096,8 @@ function FolderModel()
|
|||
this.isGmailFolder = false;
|
||||
this.isUnpaddigFolder = false;
|
||||
|
||||
this.interval = 0;
|
||||
|
||||
this.type = ko.observable(Enums.FolderType.User);
|
||||
|
||||
this.selected = ko.observable(false);
|
||||
|
@ -7277,10 +7221,21 @@ FolderModel.prototype.initComputed = function ()
|
|||
RL.data().foldersInboxUnreadCount(iUnread);
|
||||
}
|
||||
|
||||
// return 0 < iUnread ? '' + iUnread : '';
|
||||
// return 0 < iUnread && 'INBOX' === this.fullNameRaw ? '' + iUnread : '';
|
||||
return 0 < iUnread && (Enums.FolderType.Inbox === iType || Enums.FolderType.Spam === iType) ? '' + iUnread :
|
||||
(0 < iCount && Enums.FolderType.Draft === iType ? '' + iCount : '');
|
||||
if (0 < iCount)
|
||||
{
|
||||
if (Enums.FolderType.Draft === iType)
|
||||
{
|
||||
return '' + iCount;
|
||||
}
|
||||
else if (0 < iUnread && Enums.FolderType.Trash !== iType && Enums.FolderType.SentItems !== iType)
|
||||
{
|
||||
return '' + iUnread;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
// return 0 < iUnread && (Enums.FolderType.Inbox === iType || Enums.FolderType.Spam === iType) ? '' + iUnread :
|
||||
// (0 < iCount && Enums.FolderType.Draft === iType ? '' + iCount : '');
|
||||
}, this);
|
||||
|
||||
this.canBeDeleted = ko.computed(function () {
|
||||
|
@ -7395,6 +7350,7 @@ FolderModel.prototype.fullNameHash = '';
|
|||
FolderModel.prototype.delimiter = '';
|
||||
FolderModel.prototype.namespace = '';
|
||||
FolderModel.prototype.deep = 0;
|
||||
FolderModel.prototype.interval = 0;
|
||||
|
||||
FolderModel.prototype.isNamespaceFolder = false;
|
||||
FolderModel.prototype.isGmailFolder = false;
|
||||
|
@ -13705,6 +13661,67 @@ WebMailDataStorage.prototype.hideMessageBodies = function ()
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean=} bBoot = false
|
||||
* @returns {Array}
|
||||
*/
|
||||
WebMailDataStorage.prototype.getNextFolderNames = function (bBoot)
|
||||
{
|
||||
bBoot = Utils.isUnd(bBoot) ? false : !!bBoot;
|
||||
|
||||
var
|
||||
aResult = [],
|
||||
iLimit = 10,
|
||||
iUtc = moment().unix(),
|
||||
iTimeout = iUtc - 60 * 5,
|
||||
aTimeouts = [],
|
||||
fSearchFunction = function (aList) {
|
||||
_.each(aList, function (oFolder) {
|
||||
if (oFolder && 'INBOX' !== oFolder.fullNameRaw &&
|
||||
oFolder.selectable && oFolder.existen &&
|
||||
iTimeout > oFolder.interval &&
|
||||
(!bBoot || oFolder.subScribed()))
|
||||
{
|
||||
aTimeouts.push([oFolder.interval, oFolder.fullNameRaw]);
|
||||
}
|
||||
|
||||
if (oFolder && 0 < oFolder.subFolders().length)
|
||||
{
|
||||
fSearchFunction(oFolder.subFolders());
|
||||
}
|
||||
});
|
||||
}
|
||||
;
|
||||
|
||||
fSearchFunction(this.folderList());
|
||||
|
||||
aTimeouts.sort(function(a, b) {
|
||||
if (a[0] < b[0])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (a[0] > b[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
_.find(aTimeouts, function (aItem) {
|
||||
var oFolder = RL.cache().getFolderFromCacheList(aItem[1]);
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
aResult.push(aItem[1]);
|
||||
}
|
||||
|
||||
return iLimit <= aResult.length;
|
||||
});
|
||||
|
||||
return _.uniq(aResult);
|
||||
};
|
||||
|
||||
WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
||||
{
|
||||
var
|
||||
|
@ -13832,6 +13849,7 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
|
|||
iCount = 0,
|
||||
iOffset = 0,
|
||||
aList = [],
|
||||
iUtc = moment().unix(),
|
||||
aStaticList = oRainLoopData.staticMessageList,
|
||||
oJsonMessage = null,
|
||||
oMessage = null,
|
||||
|
@ -13853,6 +13871,8 @@ WebMailDataStorage.prototype.setMessageList = function (oData, bCached)
|
|||
|
||||
if (oFolder && !bCached)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
|
||||
RL.cache().setFolderHash(oData.Result.Folder, oData.Result.FolderHash);
|
||||
|
||||
if (Utils.isNormal(oData.Result.MessageCount))
|
||||
|
@ -14495,6 +14515,17 @@ WebMailAjaxRemoteStorage.prototype.folderInformation = function (fCallback, sFol
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Array} aFolders
|
||||
*/
|
||||
WebMailAjaxRemoteStorage.prototype.folderInformationMultiply = function (fCallback, aFolders)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'FolderInformationMultiply', {
|
||||
'Folders': aFolders
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
|
@ -15562,22 +15593,6 @@ MailBoxScreen.prototype.onStart = function ()
|
|||
}
|
||||
}, 1000);
|
||||
|
||||
_.delay(function () {
|
||||
var sFolder = RL.data().spamFolder();
|
||||
if (sFolder !== oData.currentFolderFullNameRaw() && '' !== sFolder)
|
||||
{
|
||||
RL.folderInformation(sFolder);
|
||||
}
|
||||
}, 1500);
|
||||
|
||||
_.delay(function () {
|
||||
var sFolder = RL.data().draftFolder();
|
||||
if (sFolder !== oData.currentFolderFullNameRaw() && '' !== sFolder)
|
||||
{
|
||||
RL.folderInformation(sFolder);
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
_.delay(function () {
|
||||
RL.quota();
|
||||
}, 5000);
|
||||
|
@ -16209,6 +16224,7 @@ RainLoopApp.prototype.folderInformation = function (sFolder, aList)
|
|||
if (oData && oData.Result && oData.Result.Hash && oData.Result.Folder)
|
||||
{
|
||||
var
|
||||
iUtc = moment().unix(),
|
||||
sHash = RL.cache().getFolderHash(oData.Result.Folder),
|
||||
oFolder = RL.cache().getFolderFromCacheList(oData.Result.Folder),
|
||||
bCheck = false,
|
||||
|
@ -16220,6 +16236,8 @@ RainLoopApp.prototype.folderInformation = function (sFolder, aList)
|
|||
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
|
||||
if (oData.Result.Hash)
|
||||
{
|
||||
RL.cache().setFolderHash(oData.Result.Folder, oData.Result.Hash);
|
||||
|
@ -16296,6 +16314,94 @@ RainLoopApp.prototype.folderInformation = function (sFolder, aList)
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean=} bBoot = false
|
||||
*/
|
||||
RainLoopApp.prototype.folderInformationMultiply = function (bBoot)
|
||||
{
|
||||
bBoot = Utils.isUnd(bBoot) ? false : !!bBoot;
|
||||
|
||||
var
|
||||
iUtc = moment().unix(),
|
||||
aFolders = RL.data().getNextFolderNames(bBoot)
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(aFolders))
|
||||
{
|
||||
this.remote().folderInformationMultiply(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success === sResult)
|
||||
{
|
||||
if (oData && oData.Result && oData.Result.List && Utils.isNonEmptyArray(oData.Result.List))
|
||||
{
|
||||
_.each(oData.Result.List, function (oItem) {
|
||||
|
||||
var
|
||||
aList = [],
|
||||
sHash = RL.cache().getFolderHash(oItem.Folder),
|
||||
oFolder = RL.cache().getFolderFromCacheList(oItem.Folder),
|
||||
bUnreadCountChange = false
|
||||
;
|
||||
|
||||
if (oFolder)
|
||||
{
|
||||
oFolder.interval = iUtc;
|
||||
|
||||
if (oItem.Hash)
|
||||
{
|
||||
RL.cache().setFolderHash(oItem.Folder, oItem.Hash);
|
||||
}
|
||||
|
||||
if (Utils.isNormal(oItem.MessageCount))
|
||||
{
|
||||
oFolder.messageCountAll(oItem.MessageCount);
|
||||
}
|
||||
|
||||
if (Utils.isNormal(oItem.MessageUnseenCount))
|
||||
{
|
||||
if (Utils.pInt(oFolder.messageCountUnread()) !== Utils.pInt(oItem.MessageUnseenCount))
|
||||
{
|
||||
bUnreadCountChange = true;
|
||||
}
|
||||
|
||||
oFolder.messageCountUnread(oItem.MessageUnseenCount);
|
||||
}
|
||||
|
||||
if (bUnreadCountChange)
|
||||
{
|
||||
RL.cache().clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw);
|
||||
}
|
||||
|
||||
if (oItem.Hash !== sHash || '' === sHash)
|
||||
{
|
||||
if (oFolder.fullNameRaw === RL.data().currentFolderFullNameRaw())
|
||||
{
|
||||
RL.reloadMessageList();
|
||||
}
|
||||
}
|
||||
else if (bUnreadCountChange)
|
||||
{
|
||||
if (oFolder.fullNameRaw === RL.data().currentFolderFullNameRaw())
|
||||
{
|
||||
aList = RL.data().messageList();
|
||||
if (Utils.isNonEmptyArray(aList))
|
||||
{
|
||||
RL.folderInformation(oFolder.fullNameRaw, aList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (bBoot)
|
||||
{
|
||||
RL.folderInformationMultiply(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, aFolders);
|
||||
}
|
||||
};
|
||||
|
||||
RainLoopApp.prototype.setMessageSeen = function (oMessage)
|
||||
{
|
||||
if (oMessage.unseen())
|
||||
|
@ -16644,6 +16750,30 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
RL.socialUsers(true);
|
||||
}
|
||||
|
||||
RL.sub('interval.2m', function () {
|
||||
RL.folderInformation('INBOX');
|
||||
});
|
||||
|
||||
RL.sub('interval.2m', function () {
|
||||
var sF = RL.data().currentFolderFullNameRaw();
|
||||
if ('INBOX' !== sF)
|
||||
{
|
||||
RL.folderInformation(sF);
|
||||
}
|
||||
});
|
||||
|
||||
RL.sub('interval.3m', function () {
|
||||
RL.folderInformationMultiply();
|
||||
});
|
||||
|
||||
RL.sub('interval.5m', function () {
|
||||
RL.quota();
|
||||
});
|
||||
|
||||
_.delay(function () {
|
||||
RL.folderInformationMultiply(true);
|
||||
}, 500);
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
RL.emailsPicsHashes();
|
||||
|
@ -16654,15 +16784,9 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
RL.cache().setServicesData(oData.Result);
|
||||
}
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
RL.sub('interval.5m', function () {
|
||||
RL.quota();
|
||||
});
|
||||
}, 2000);
|
||||
|
||||
RL.sub('interval.2m', function () {
|
||||
RL.folderInformation('INBOX');
|
||||
});
|
||||
|
||||
Plugins.runHook('rl-start-user-screens');
|
||||
}
|
||||
|
|
10
rainloop/v/0.0.0/static/js/app.min.js
vendored
10
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue