mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-10 06:58:27 +03:00
Underscore.js _.uniq(_.compact( to native Array.filter((value, index, self) => !!value && self.indexOf(value) == index) Underscore.js _.compact to native Array.filter(value => !!value) Underscore.js _.uniq to native Array.filter((value, index, self) => self.indexOf(value) == index) Underscore.js _.values to native Object.values Underscore.js _.flatten to native Array.flat Underscore.js _.union to native Array.concat + unique filter Underscore.js _.reduce to native Array.reduce Underscore.js _.escape replaced with advanced htmlspecialchars() Underscore.js _.memoize replaced Now Underscore.js is a slim custom version (only _.debounce, _.defer & _.throttle)
34 lines
837 B
JavaScript
34 lines
837 B
JavaScript
import ko from 'ko';
|
|
|
|
// import Remote from 'Remote/User/Ajax';
|
|
|
|
class TemplateUserStore {
|
|
constructor() {
|
|
this.templates = ko.observableArray([]);
|
|
this.templates.loading = ko.observable(false).extend({ throttle: 100 });
|
|
|
|
this.templatesNames = ko.observableArray([]).extend({ throttle: 1000 });
|
|
this.templatesNames.skipFirst = true;
|
|
|
|
this.subscribers();
|
|
}
|
|
|
|
subscribers() {
|
|
this.templates.subscribe((list) => {
|
|
this.templatesNames(list.map(item => (item ? item.name : null)).filter(value => !!value));
|
|
});
|
|
|
|
// this.templatesNames.subscribe((aList) => {
|
|
// if (this.templatesNames.skipFirst)
|
|
// {
|
|
// this.templatesNames.skipFirst = false;
|
|
// }
|
|
// else if (aList && 1 < aList.length)
|
|
// {
|
|
// Remote.templatesSortOrder(null, aList);
|
|
// }
|
|
// });
|
|
}
|
|
}
|
|
|
|
export default new TemplateUserStore();
|