mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +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
|
|
@ -9,6 +9,7 @@ function MailBoxMessageListViewModel()
|
|||
KnoinAbstractViewModel.call(this, 'Right', 'MailMessageList');
|
||||
|
||||
this.sLastUid = null;
|
||||
this.bPrefetch = false;
|
||||
this.emptySubjectValue = '';
|
||||
|
||||
var oData = RL.data();
|
||||
|
|
@ -796,6 +797,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 ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue