mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-27 19:19:21 +03:00
Merge quota requests into folders request
This commit is contained in:
parent
20eb01de08
commit
8d3bcdc2f2
9 changed files with 45 additions and 51 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import 'External/User/ko';
|
||||
|
||||
import { isArray, arrayLength, pInt, pString, forEachObjectValue } from 'Common/Utils';
|
||||
import { isPosNumeric, delegateRunOnDestroy, mailToHelper } from 'Common/UtilsUser';
|
||||
import { isArray, arrayLength, pString, forEachObjectValue } from 'Common/Utils';
|
||||
import { delegateRunOnDestroy, mailToHelper } from 'Common/UtilsUser';
|
||||
|
||||
import {
|
||||
Capa,
|
||||
|
|
@ -54,7 +54,6 @@ import { IdentityUserStore } from 'Stores/User/Identity';
|
|||
import { FolderUserStore } from 'Stores/User/Folder';
|
||||
import { PgpUserStore } from 'Stores/User/Pgp';
|
||||
import { MessageUserStore } from 'Stores/User/Message';
|
||||
import { QuotaUserStore } from 'Stores/User/Quota';
|
||||
import { ThemeStore } from 'Stores/Theme';
|
||||
|
||||
import * as Local from 'Storage/Client';
|
||||
|
|
@ -89,7 +88,6 @@ class AppUser extends AbstractApp {
|
|||
|
||||
this.moveCache = {};
|
||||
|
||||
this.quotaDebounce = this.quota.debounce(30000);
|
||||
this.moveOrDeleteResponseHelper = this.moveOrDeleteResponseHelper.bind(this);
|
||||
|
||||
this.messagesMoveTrigger = this.messagesMoveTrigger.debounce(500);
|
||||
|
|
@ -468,19 +466,6 @@ class AppUser extends AbstractApp {
|
|||
});
|
||||
}
|
||||
|
||||
quota() {
|
||||
Remote.quota((iError, data) => {
|
||||
if (
|
||||
!iError &&
|
||||
1 < arrayLength(data.Result) &&
|
||||
isPosNumeric(data.Result[0]) &&
|
||||
isPosNumeric(data.Result[1])
|
||||
) {
|
||||
QuotaUserStore.populateData(pInt(data.Result[1]), pInt(data.Result[0]));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} folder
|
||||
* @param {Array=} list = []
|
||||
|
|
@ -844,7 +829,7 @@ class AppUser extends AbstractApp {
|
|||
}, refreshFolders);
|
||||
|
||||
// Every 15 minutes
|
||||
setInterval(()=>this.quota() | this.foldersReload(), 900000);
|
||||
setInterval(()=>this.foldersReload(), 900000);
|
||||
|
||||
ContactUserStore.init();
|
||||
|
||||
|
|
@ -855,7 +840,6 @@ class AppUser extends AbstractApp {
|
|||
if (getFolderInboxName() !== cF) {
|
||||
this.folderInformation(cF);
|
||||
}
|
||||
this.quota();
|
||||
FolderUserStore.listStatusSupported() || this.folderInformationMultiply(true);
|
||||
}, 1000);
|
||||
|
||||
|
|
|
|||
|
|
@ -149,6 +149,8 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
|||
FolderUserStore.sortSupported(!!this.IsSortSupported);
|
||||
FolderUserStore.metadataSupported(!!this.IsMetadataSupported);
|
||||
FolderUserStore.listStatusSupported(!!this.IsListStatusSupported);
|
||||
FolderUserStore.quotaUsage(this.quotaUsage);
|
||||
FolderUserStore.quotaLimit(this.quotaLimit);
|
||||
|
||||
FolderUserStore.sentFolder(normalizeFolder(SettingsGet('SentFolder')));
|
||||
FolderUserStore.draftFolder(normalizeFolder(SettingsGet('DraftFolder')));
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ export const FolderUserStore = new class {
|
|||
listStatusSupported: false,
|
||||
// sortMode: '',
|
||||
|
||||
quotaLimit: 0,
|
||||
quotaUsage: 0,
|
||||
|
||||
sentFolder: '',
|
||||
draftFolder: '',
|
||||
spamFolder: '',
|
||||
|
|
@ -103,6 +106,11 @@ export const FolderUserStore = new class {
|
|||
trashFolder: fSetSystemFolderType(FolderType.Trash),
|
||||
archiveFolder: fSetSystemFolderType(FolderType.Archive)
|
||||
});
|
||||
|
||||
this.quotaPercentage = ko.computed(() => {
|
||||
const quota = this.quotaLimit(), usage = this.quotaUsage();
|
||||
return 0 < quota ? Math.ceil((usage / quota) * 100) : 0;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
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);
|
||||
}
|
||||
};
|
||||
|
|
@ -31,7 +31,6 @@ import {
|
|||
} from 'Common/Cache';
|
||||
|
||||
import { AppUserStore } from 'Stores/User/App';
|
||||
import { QuotaUserStore } from 'Stores/User/Quota';
|
||||
import { SettingsUserStore } from 'Stores/User/Settings';
|
||||
import { FolderUserStore } from 'Stores/User/Folder';
|
||||
import { MessageUserStore } from 'Stores/User/Message';
|
||||
|
|
@ -84,7 +83,7 @@ export class MailMessageList extends AbstractViewRight {
|
|||
|
||||
initOnStartOrLangChange(() => this.emptySubjectValue = i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT'));
|
||||
|
||||
this.userUsageProc = QuotaUserStore.percentage;
|
||||
this.userUsageProc = FolderUserStore.quotaPercentage;
|
||||
|
||||
this.addObservables({
|
||||
moveDropdownTrigger: false,
|
||||
|
|
@ -908,9 +907,9 @@ export class MailMessageList extends AbstractViewRight {
|
|||
|
||||
quotaTooltip() {
|
||||
return i18n('MESSAGE_LIST/QUOTA_SIZE', {
|
||||
SIZE: FileInfo.friendlySize(QuotaUserStore.usage()),
|
||||
PROC: QuotaUserStore.percentage(),
|
||||
LIMIT: FileInfo.friendlySize(QuotaUserStore.quota())
|
||||
SIZE: FileInfo.friendlySize(FolderUserStore.quotaUsage()),
|
||||
PROC: FolderUserStore.quotaPercentage(),
|
||||
LIMIT: FileInfo.friendlySize(FolderUserStore.quotaLimit())
|
||||
}).replace(/<[^>]+>/g, '');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue