snappymail/dev/Stores/User/Quota.js
djmaze 6a454ec624 Convert user stores to single object instances
Removed unused ContactUserStore.exportingCsv and ContactUserStore.exportingVcf
2021-03-10 22:41:35 +01:00

25 lines
470 B
JavaScript

import ko from 'ko';
export const QuotaUserStore = new class {
constructor() {
this.quota = ko.observable(0);
this.usage = ko.observable(0);
this.percentage = ko.computed(() => {
const quota = this.quota(),
usage = this.usage();
return 0 < quota ? Math.ceil((usage / quota) * 100) : 0;
});
}
/**
* @param {number} quota
* @param {number} usage
*/
populateData(quota, usage) {
this.quota(quota * 1024);
this.usage(usage * 1024);
}
};