mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
Simple prefetch functionality (ifvisible.js)
config: [labs] allow_prefetch
This commit is contained in:
parent
b7e135a553
commit
38672e1672
18 changed files with 988 additions and 28 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*! RainLoop Webmail Main Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
(function (window, $, ko, crossroads, hasher, moment, Jua, _) {
|
||||
(function (window, $, ko, crossroads, hasher, moment, Jua, _, ifvisible) {
|
||||
|
||||
'use strict';
|
||||
|
||||
|
|
@ -1153,7 +1153,7 @@ Utils.log = function (sDesc)
|
|||
|
||||
/**
|
||||
* @param {number} iCode
|
||||
* @param {ыекштп=} mMessage = ''
|
||||
* @param {*=} mMessage = ''
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.getNotification = function (iCode, mMessage)
|
||||
|
|
@ -6328,8 +6328,6 @@ function MessageModel()
|
|||
this.toEmailsString = ko.observable('');
|
||||
this.senderEmailsString = ko.observable('');
|
||||
|
||||
this.prefetched = false;
|
||||
|
||||
this.emails = [];
|
||||
|
||||
this.from = [];
|
||||
|
|
@ -6539,8 +6537,6 @@ MessageModel.prototype.clear = function ()
|
|||
this.toEmailsString('');
|
||||
this.senderEmailsString('');
|
||||
|
||||
this.prefetched = false;
|
||||
|
||||
this.emails = [];
|
||||
|
||||
this.from = [];
|
||||
|
|
@ -6610,8 +6606,6 @@ MessageModel.prototype.initByJson = function (oJsonMessage)
|
|||
this.uid = oJsonMessage.Uid;
|
||||
this.requestHash = oJsonMessage.RequestHash;
|
||||
|
||||
this.prefetched = false;
|
||||
|
||||
this.size(Utils.pInt(oJsonMessage.Size));
|
||||
|
||||
this.from = MessageModel.initEmailsFromJson(oJsonMessage.From);
|
||||
|
|
@ -11220,6 +11214,7 @@ function MailBoxMessageListViewModel()
|
|||
KnoinAbstractViewModel.call(this, 'Right', 'MailMessageList');
|
||||
|
||||
this.sLastUid = null;
|
||||
this.bPrefetch = false;
|
||||
this.emptySubjectValue = '';
|
||||
|
||||
var oData = RL.data();
|
||||
|
|
@ -12007,6 +12002,51 @@ MailBoxMessageListViewModel.prototype.onBuild = function (oDom)
|
|||
}, this).extend({'notify': 'always'});
|
||||
|
||||
this.initUploaderForAppend();
|
||||
|
||||
if (!Globals.bMobileDevice && !!RL.settingsGet('AllowPrefetch') && ifvisible)
|
||||
{
|
||||
ifvisible.setIdleDuration(10);
|
||||
|
||||
ifvisible.idle(function () {
|
||||
self.prefetchNextTick();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.prefetchNextTick = function ()
|
||||
{
|
||||
if (!this.bPrefetch && !ifvisible.now() && this.viewModelVisibility())
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
oCache = RL.cache(),
|
||||
oMessage = _.find(this.messageList(), function (oMessage) {
|
||||
return oMessage &&
|
||||
!oCache.hasRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);
|
||||
})
|
||||
;
|
||||
|
||||
if (oMessage)
|
||||
{
|
||||
this.bPrefetch = true;
|
||||
|
||||
RL.cache().addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);
|
||||
|
||||
RL.remote().message(function (sResult, oData) {
|
||||
|
||||
var bNext = !!(Enums.StorageResultType.Success === sResult && oData && oData.Result);
|
||||
|
||||
_.delay(function () {
|
||||
self.bPrefetch = false;
|
||||
if (bNext)
|
||||
{
|
||||
self.prefetchNextTick();
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
}, oMessage.folderFullNameRaw, oMessage.uid);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.composeClick = function ()
|
||||
|
|
@ -17509,4 +17549,4 @@ if (window.SimplePace) {
|
|||
window.SimplePace.add(10);
|
||||
}
|
||||
|
||||
}(window, jQuery, ko, crossroads, hasher, moment, Jua, _));
|
||||
}(window, jQuery, ko, crossroads, hasher, moment, Jua, _, ifvisible));
|
||||
Loading…
Add table
Add a link
Reference in a new issue