snappymail/dev/Stores/User/Template.js

39 lines
825 B
JavaScript
Raw Normal View History

import ko from 'ko';
import _ from '_';
2016-06-30 08:02:45 +08:00
// import Remote from 'Remote/User/Ajax';
2016-06-30 08:02:45 +08:00
class TemplateUserStore
2016-06-30 08:02:45 +08:00
{
constructor() {
this.templates = ko.observableArray([]);
this.templates.loading = ko.observable(false).extend({throttle: 100});
2016-06-30 08:02:45 +08:00
this.templatesNames = ko.observableArray([]).extend({throttle: 1000});
this.templatesNames.skipFirst = true;
2016-06-30 08:02:45 +08:00
this.subscribers();
}
2016-06-30 08:02:45 +08:00
subscribers() {
2016-06-30 08:02:45 +08:00
this.templates.subscribe((list) => {
this.templatesNames(_.compact(_.map(list, (item) => (item ? item.name : null))));
});
// this.templatesNames.subscribe((aList) => {
2016-06-30 08:02:45 +08:00
// if (this.templatesNames.skipFirst)
// {
// this.templatesNames.skipFirst = false;
// }
// else if (aList && 1 < aList.length)
// {
// Remote.templatesSortOrder(null, aList);
// }
// });
}
}
2016-06-30 08:02:45 +08:00
export default new TemplateUserStore();