2015-03-14 07:10:00 +08:00
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var
|
|
|
|
_ = require('_'),
|
|
|
|
|
2015-03-16 05:58:50 +08:00
|
|
|
AbstractAjaxPromises = require('Promises/AbstractAjax')
|
2015-03-14 07:10:00 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
* @extends AbstractAjaxPromises
|
|
|
|
*/
|
|
|
|
function PromisesUserAjax()
|
|
|
|
{
|
|
|
|
AbstractAjaxPromises.call(this);
|
|
|
|
|
2015-03-16 05:58:50 +08:00
|
|
|
this.messageListSimpleHash = '';
|
|
|
|
this.messageListSimpleCache = null;
|
2015-03-14 07:10:00 +08:00
|
|
|
}
|
|
|
|
|
2015-03-16 05:58:50 +08:00
|
|
|
_.extend(PromisesUserAjax.prototype, AbstractAjaxPromises.prototype);
|
|
|
|
|
|
|
|
PromisesUserAjax.prototype.messageListSimple = function (sFolder, aUids, fTrigger)
|
2015-03-14 07:10:00 +08:00
|
|
|
{
|
|
|
|
var self = this, sHash = sFolder + '~' + aUids.join('/');
|
2015-03-16 05:58:50 +08:00
|
|
|
if (sHash === this.messageListSimpleHash && this.messageListSimpleCache)
|
2015-03-14 07:10:00 +08:00
|
|
|
{
|
2015-03-16 05:58:50 +08:00
|
|
|
return this.fastResolve(this.messageListSimpleCache);
|
2015-03-14 07:10:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.abort('MessageListSimple')
|
2015-03-16 05:58:50 +08:00
|
|
|
.postRequest('MessageListSimple', fTrigger, {
|
2015-03-14 07:10:00 +08:00
|
|
|
'Folder': sFolder,
|
|
|
|
'Uids': aUids
|
|
|
|
}).then(function (aData) {
|
|
|
|
|
2015-03-16 05:58:50 +08:00
|
|
|
var
|
|
|
|
MessageSimpleModel = require('Model/MessageSimple'),
|
|
|
|
aResult = _.compact(_.map(aData, function (aItem) {
|
|
|
|
return MessageSimpleModel.newInstanceFromJson(aItem);
|
|
|
|
}))
|
|
|
|
;
|
2015-03-14 07:10:00 +08:00
|
|
|
|
2015-03-16 05:58:50 +08:00
|
|
|
self.messageListSimpleHash = sHash;
|
|
|
|
self.messageListSimpleCache = aResult;
|
2015-03-14 07:10:00 +08:00
|
|
|
|
|
|
|
return aResult;
|
|
|
|
})
|
|
|
|
;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = new PromisesUserAjax();
|
|
|
|
|
|
|
|
}());
|