Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
64 lines
1.5 KiB
JavaScript
Executable file
64 lines
1.5 KiB
JavaScript
Executable file
define(function(require, exports, module) {
|
|
'use strict';
|
|
|
|
var Abstract = require('./abstract');
|
|
var Calc = require('common/calc');
|
|
var core = require('core');
|
|
var denodeifyAll = require('common/promise').denodeifyAll;
|
|
|
|
function IcalComponent() {
|
|
Abstract.apply(this, arguments);
|
|
|
|
denodeifyAll(this, [
|
|
'findRecurrencesBefore'
|
|
]);
|
|
}
|
|
module.exports = IcalComponent;
|
|
|
|
IcalComponent.prototype = {
|
|
__proto__: Abstract.prototype,
|
|
|
|
_store: 'icalComponents',
|
|
|
|
/** disable caching */
|
|
_addToCache: function() {},
|
|
_removeFromCache: function() {},
|
|
|
|
_createModel: function(object) {
|
|
return object;
|
|
},
|
|
|
|
_detectPersistType: function(object) {
|
|
// always fire update.
|
|
return 'update';
|
|
},
|
|
|
|
/**
|
|
* Finds all components which have recurrences
|
|
* that are not expanded beyond the given date.
|
|
*
|
|
* @param {Date} maxDate max date to find.
|
|
* @param {Function} callback results of search [err, [icalComp, ...]].
|
|
*/
|
|
findRecurrencesBefore: function(maxDate, callback) {
|
|
var trans = core.db.transaction(this._store, 'readwrite');
|
|
|
|
trans.onerror = function(event) {
|
|
callback(event.target.error.name);
|
|
};
|
|
|
|
var time = Calc.dateToTransport(maxDate);
|
|
var utc = time.utc;
|
|
var range = IDBKeyRange.bound(0, utc);
|
|
var store = trans.objectStore(this._store);
|
|
var idx = store.index('lastRecurrenceId');
|
|
|
|
var req = idx.mozGetAll(range);
|
|
|
|
req.onsuccess = function(event) {
|
|
callback(null, event.target.result);
|
|
};
|
|
}
|
|
};
|
|
|
|
});
|