snappymail/dev/Stores/User/Account.js
djmaze dca0ff02ed Use jQuery.slim
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)
2020-07-23 16:06:16 +02:00

49 lines
1.1 KiB
JavaScript

import ko from 'ko';
import { Magics } from 'Common/Enums';
import * as Settings from 'Storage/Settings';
class AccountUserStore {
constructor() {
this.email = ko.observable('');
this.parentEmail = ko.observable('');
this.signature = ko.observable('');
this.accounts = ko.observableArray([]);
this.accounts.loading = ko.observable(false).extend({ throttle: Magics.Time100ms });
this.computers();
}
computers() {
this.accountsEmails = ko.computed(
() => this.accounts().map(item => (item ? item.email : null)).filter(value => !!value)
);
this.accountsUnreadCount = ko.computed(() => 0);
// this.accountsUnreadCount = ko.computed(() => {
// let result = 0;
// this.accounts().forEach(item => {
// if (item)
// {
// result += item.count();
// }
// });
// return result;
// });
}
populate() {
this.email(Settings.settingsGet('Email'));
this.parentEmail(Settings.settingsGet('ParentEmail'));
}
/**
* @returns {boolean}
*/
isRootAccount() {
return '' === this.parentEmail();
}
}
export default new AccountUserStore();