2020-09-16 22:33:53 +08:00
|
|
|
import { AbstractCollectionModel } from 'Model/AbstractCollection';
|
|
|
|
|
2020-09-16 15:32:36 +08:00
|
|
|
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
2021-12-07 21:03:30 +08:00
|
|
|
import { isArray, getKeyByValue, forEachObjectEntry, b64EncodeJSONSafe } from 'Common/Utils';
|
2021-10-14 15:43:20 +08:00
|
|
|
import { ClientSideKeyName, FolderType, FolderMetadataKeys } from 'Common/EnumsUser';
|
2021-12-08 21:08:25 +08:00
|
|
|
import { getFolderFromCacheList, setFolder, setFolderInboxName, setFolderHash } from 'Common/Cache';
|
2022-02-11 19:21:16 +08:00
|
|
|
import { Settings, SettingsGet, fireEvent } from 'Common/Globals';
|
2020-09-16 15:32:36 +08:00
|
|
|
|
|
|
|
import * as Local from 'Storage/Client';
|
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
import { AppUserStore } from 'Stores/User/App';
|
|
|
|
import { FolderUserStore } from 'Stores/User/Folder';
|
2021-08-25 03:10:49 +08:00
|
|
|
import { MessageUserStore } from 'Stores/User/Message';
|
2021-03-30 04:05:08 +08:00
|
|
|
import { SettingsUserStore } from 'Stores/User/Settings';
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
import ko from 'ko';
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-12-09 18:24:30 +08:00
|
|
|
import { sortFolders } from 'Common/UtilsUser';
|
2021-01-26 05:00:13 +08:00
|
|
|
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
import { AbstractModel } from 'Knoin/AbstractModel';
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-12-31 20:30:05 +08:00
|
|
|
import { koComputable } from 'External/ko';
|
|
|
|
|
2021-12-08 18:06:42 +08:00
|
|
|
//import { mailBox } from 'Common/Links';
|
|
|
|
|
2021-01-27 07:26:31 +08:00
|
|
|
const
|
2021-12-09 18:24:30 +08:00
|
|
|
isPosNumeric = value => null != value && /^[0-9]*$/.test(value.toString()),
|
|
|
|
|
|
|
|
normalizeFolder = sFolderFullName => ('' === sFolderFullName
|
|
|
|
|| UNUSED_OPTION_VALUE === sFolderFullName
|
|
|
|
|| null !== getFolderFromCacheList(sFolderFullName))
|
|
|
|
? sFolderFullName
|
|
|
|
: '',
|
|
|
|
|
|
|
|
SystemFolders = {
|
|
|
|
Inbox: 0,
|
|
|
|
Sent: 0,
|
|
|
|
Drafts: 0,
|
|
|
|
Spam: 0,
|
|
|
|
Trash: 0,
|
|
|
|
Archive: 0
|
|
|
|
};
|
2021-08-24 21:53:39 +08:00
|
|
|
|
2020-09-16 22:33:53 +08:00
|
|
|
export class FolderCollectionModel extends AbstractCollectionModel
|
2020-09-16 15:32:36 +08:00
|
|
|
{
|
2020-09-16 22:33:53 +08:00
|
|
|
/*
|
2020-09-16 15:32:36 +08:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.CountRec
|
|
|
|
this.IsThreadsSupported
|
2020-09-16 21:44:36 +08:00
|
|
|
this.Namespace;
|
2020-09-16 15:32:36 +08:00
|
|
|
this.Optimized
|
|
|
|
this.SystemFolders
|
2021-11-03 09:28:01 +08:00
|
|
|
this.Capabilities
|
2020-09-16 15:32:36 +08:00
|
|
|
}
|
2020-09-16 22:33:53 +08:00
|
|
|
*/
|
2020-09-16 15:32:36 +08:00
|
|
|
|
|
|
|
/**
|
2020-09-16 21:44:36 +08:00
|
|
|
* @param {?Object} json
|
2020-09-16 15:32:36 +08:00
|
|
|
* @returns {FolderCollectionModel}
|
|
|
|
*/
|
2020-09-16 22:33:53 +08:00
|
|
|
static reviveFromJson(object) {
|
2020-12-10 21:19:03 +08:00
|
|
|
const expandedFolders = Local.get(ClientSideKeyName.ExpandedFolders);
|
2021-08-24 21:53:39 +08:00
|
|
|
if (object && object.SystemFolders) {
|
2021-12-01 20:54:35 +08:00
|
|
|
forEachObjectEntry(SystemFolders, key =>
|
|
|
|
SystemFolders[key] = SettingsGet(key+'Folder') || object.SystemFolders[FolderType[key]]
|
|
|
|
);
|
2021-08-24 21:53:39 +08:00
|
|
|
}
|
|
|
|
|
2021-12-08 21:08:25 +08:00
|
|
|
const result = super.reviveFromJson(object, oFolder => {
|
|
|
|
let oCacheFolder = getFolderFromCacheList(oFolder.FullName),
|
2021-12-01 20:54:35 +08:00
|
|
|
type = FolderType[getKeyByValue(SystemFolders, oFolder.FullName)];
|
2021-08-25 06:12:46 +08:00
|
|
|
|
2021-12-08 21:08:25 +08:00
|
|
|
if (!oCacheFolder) {
|
2021-08-25 06:19:39 +08:00
|
|
|
oCacheFolder = FolderModel.reviveFromJson(oFolder);
|
|
|
|
if (!oCacheFolder)
|
|
|
|
return null;
|
2021-08-25 06:12:46 +08:00
|
|
|
|
2021-12-01 20:54:35 +08:00
|
|
|
if (1 == type) {
|
2020-10-18 17:46:22 +08:00
|
|
|
oCacheFolder.type(FolderType.Inbox);
|
2021-12-08 21:08:25 +08:00
|
|
|
setFolderInboxName(oFolder.FullName);
|
2020-10-18 17:46:22 +08:00
|
|
|
}
|
2021-12-08 21:08:25 +08:00
|
|
|
setFolder(oCacheFolder);
|
2020-10-18 17:46:22 +08:00
|
|
|
}
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-08-25 06:19:39 +08:00
|
|
|
if (1 < type) {
|
|
|
|
oCacheFolder.type(type);
|
|
|
|
}
|
2021-08-24 21:53:39 +08:00
|
|
|
|
2021-08-25 06:19:39 +08:00
|
|
|
oCacheFolder.collapsed(!expandedFolders
|
|
|
|
|| !isArray(expandedFolders)
|
2021-12-07 21:03:30 +08:00
|
|
|
|| !expandedFolders.includes(oCacheFolder.fullName));
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-08-25 06:19:39 +08:00
|
|
|
if (oFolder.Extended) {
|
|
|
|
if (oFolder.Extended.Hash) {
|
2021-12-08 21:08:25 +08:00
|
|
|
setFolderHash(oCacheFolder.fullName, oFolder.Extended.Hash);
|
2021-08-25 06:19:39 +08:00
|
|
|
}
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-08-25 06:19:39 +08:00
|
|
|
if (null != oFolder.Extended.MessageCount) {
|
|
|
|
oCacheFolder.messageCountAll(oFolder.Extended.MessageCount);
|
|
|
|
}
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-08-25 06:19:39 +08:00
|
|
|
if (null != oFolder.Extended.MessageUnseenCount) {
|
|
|
|
oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount);
|
2020-09-16 15:32:36 +08:00
|
|
|
}
|
2020-10-18 17:46:22 +08:00
|
|
|
}
|
|
|
|
return oCacheFolder;
|
|
|
|
});
|
2021-12-08 21:08:25 +08:00
|
|
|
|
|
|
|
let i = result.length;
|
|
|
|
if (i) {
|
2021-12-09 18:24:30 +08:00
|
|
|
sortFolders(result);
|
2021-12-08 21:08:25 +08:00
|
|
|
try {
|
|
|
|
while (i--) {
|
|
|
|
let folder = result[i], parent = getFolderFromCacheList(folder.parentName);
|
|
|
|
if (parent) {
|
|
|
|
parent.subFolders.unshift(folder);
|
|
|
|
result.splice(i,1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2020-09-16 15:32:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
storeIt() {
|
2021-11-24 22:18:13 +08:00
|
|
|
FolderUserStore.displaySpecSetting(Settings.app('folderSpecLimit') < this.CountRec);
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-12-01 20:54:35 +08:00
|
|
|
if (!(
|
2021-08-24 21:53:39 +08:00
|
|
|
SettingsGet('SentFolder') +
|
2021-12-01 20:54:35 +08:00
|
|
|
SettingsGet('DraftsFolder') +
|
2021-08-24 21:53:39 +08:00
|
|
|
SettingsGet('SpamFolder') +
|
|
|
|
SettingsGet('TrashFolder') +
|
2021-12-01 19:04:17 +08:00
|
|
|
SettingsGet('ArchiveFolder')
|
|
|
|
)
|
2021-08-24 21:53:39 +08:00
|
|
|
) {
|
2021-12-01 20:54:35 +08:00
|
|
|
FolderUserStore.saveSystemFolders(SystemFolders);
|
2021-08-24 21:53:39 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
FolderUserStore.folderList(this);
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-12-01 19:04:17 +08:00
|
|
|
FolderUserStore.namespace = this.Namespace;
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
AppUserStore.threadsAllowed(!!(Settings.app('useImapThread') && this.IsThreadsSupported));
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
FolderUserStore.folderListOptimized(!!this.Optimized);
|
2021-11-01 23:26:07 +08:00
|
|
|
FolderUserStore.quotaUsage(this.quotaUsage);
|
|
|
|
FolderUserStore.quotaLimit(this.quotaLimit);
|
2021-11-03 09:28:01 +08:00
|
|
|
FolderUserStore.capabilities(this.Capabilities);
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-12-01 20:54:35 +08:00
|
|
|
FolderUserStore.sentFolder(normalizeFolder(SystemFolders.Sent));
|
|
|
|
FolderUserStore.draftsFolder(normalizeFolder(SystemFolders.Drafts));
|
|
|
|
FolderUserStore.spamFolder(normalizeFolder(SystemFolders.Spam));
|
|
|
|
FolderUserStore.trashFolder(normalizeFolder(SystemFolders.Trash));
|
|
|
|
FolderUserStore.archiveFolder(normalizeFolder(SystemFolders.Archive));
|
2020-09-16 15:32:36 +08:00
|
|
|
|
2021-08-24 21:53:39 +08:00
|
|
|
// FolderUserStore.folderList.valueHasMutated();
|
2020-09-16 15:32:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-01-26 05:00:13 +08:00
|
|
|
|
2021-10-21 23:15:00 +08:00
|
|
|
function getKolabFolderName(type)
|
|
|
|
{
|
|
|
|
const types = {
|
|
|
|
configuration: 'CONFIGURATION',
|
|
|
|
event: 'CALENDAR',
|
|
|
|
contact: 'CONTACTS',
|
|
|
|
task: 'TASKS',
|
|
|
|
note: 'NOTES',
|
|
|
|
file: 'FILES',
|
|
|
|
journal: 'JOURNAL'
|
|
|
|
};
|
|
|
|
return types[type] ? 'Kolab ' + i18n('SETTINGS_FOLDERS/TYPE_' + types[type]) : '';
|
|
|
|
}
|
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
function getSystemFolderName(type, def)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case FolderType.Inbox:
|
2021-08-20 21:40:07 +08:00
|
|
|
case FolderType.Sent:
|
|
|
|
case FolderType.Drafts:
|
2021-01-26 05:00:13 +08:00
|
|
|
case FolderType.Trash:
|
|
|
|
case FolderType.Archive:
|
2021-10-21 23:15:00 +08:00
|
|
|
return i18n('FOLDER_LIST/' + getKeyByValue(FolderType, type).toUpperCase() + '_NAME');
|
|
|
|
case FolderType.Spam:
|
|
|
|
return i18n('GLOBAL/SPAM');
|
2021-01-26 05:00:13 +08:00
|
|
|
// no default
|
|
|
|
}
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class FolderModel extends AbstractModel {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.fullName = '';
|
|
|
|
this.delimiter = '';
|
|
|
|
this.deep = 0;
|
2021-03-18 20:52:56 +08:00
|
|
|
this.expires = 0;
|
2021-10-13 21:42:56 +08:00
|
|
|
this.metadata = {};
|
2021-01-26 05:00:13 +08:00
|
|
|
|
|
|
|
this.exists = true;
|
|
|
|
|
2021-12-07 21:03:30 +08:00
|
|
|
// this.hash = '';
|
|
|
|
// this.uidNext = 0;
|
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
this.addObservables({
|
|
|
|
name: '',
|
|
|
|
type: FolderType.User,
|
2021-08-25 22:27:17 +08:00
|
|
|
selectable: false,
|
2021-01-26 05:00:13 +08:00
|
|
|
|
|
|
|
focused: false,
|
|
|
|
selected: false,
|
|
|
|
edited: false,
|
|
|
|
subscribed: true,
|
2021-11-24 22:18:13 +08:00
|
|
|
checkable: false, // Check for new messages
|
2022-01-28 06:07:34 +08:00
|
|
|
askDelete: false,
|
2021-01-26 05:00:13 +08:00
|
|
|
|
|
|
|
nameForEdit: '',
|
2021-12-13 21:32:15 +08:00
|
|
|
errorMsg: '',
|
2021-01-26 05:00:13 +08:00
|
|
|
|
|
|
|
privateMessageCountAll: 0,
|
|
|
|
privateMessageCountUnread: 0,
|
|
|
|
|
2021-10-14 16:37:07 +08:00
|
|
|
kolabType: null,
|
2021-10-14 15:43:20 +08:00
|
|
|
|
2021-11-04 02:25:52 +08:00
|
|
|
collapsed: true
|
2021-01-26 05:00:13 +08:00
|
|
|
});
|
|
|
|
|
2021-10-15 17:58:06 +08:00
|
|
|
this.addSubscribables({
|
|
|
|
kolabType: sValue => this.metadata[FolderMetadataKeys.KolabFolderType] = sValue
|
|
|
|
});
|
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
this.subFolders = ko.observableArray(new FolderCollectionModel);
|
|
|
|
this.actionBlink = ko.observable(false).extend({ falseTimeout: 1000 });
|
|
|
|
}
|
|
|
|
|
2021-12-07 21:03:30 +08:00
|
|
|
/**
|
|
|
|
* For url safe '/#/mailbox/...' path
|
|
|
|
*/
|
|
|
|
get fullNameHash() {
|
|
|
|
return this.fullName.replace(/[^a-z0-9._-]+/giu, b64EncodeJSONSafe);
|
|
|
|
// return /^[a-z0-9._-]+$/iu.test(this.fullName) ? this.fullName : b64EncodeJSONSafe(this.fullName);
|
|
|
|
}
|
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
/**
|
|
|
|
* @static
|
|
|
|
* @param {FetchJsonFolder} json
|
|
|
|
* @returns {?FolderModel}
|
|
|
|
*/
|
|
|
|
static reviveFromJson(json) {
|
|
|
|
const folder = super.reviveFromJson(json);
|
|
|
|
if (folder) {
|
2021-12-09 18:24:30 +08:00
|
|
|
const path = folder.fullName.split(folder.delimiter),
|
|
|
|
type = (folder.metadata[FolderMetadataKeys.KolabFolderType]
|
|
|
|
|| folder.metadata[FolderMetadataKeys.KolabFolderTypeShared]
|
|
|
|
|| ''
|
|
|
|
).split('.')[0];
|
|
|
|
|
2021-12-08 18:06:42 +08:00
|
|
|
folder.deep = path.length - 1;
|
|
|
|
path.pop();
|
|
|
|
folder.parentName = path.join(folder.delimiter);
|
2021-01-26 05:00:13 +08:00
|
|
|
|
2021-10-19 18:44:09 +08:00
|
|
|
type && 'mail' != type && folder.kolabType(type);
|
2021-10-14 15:43:20 +08:00
|
|
|
|
2021-12-31 20:30:05 +08:00
|
|
|
folder.messageCountAll = koComputable({
|
2021-01-26 05:00:13 +08:00
|
|
|
read: folder.privateMessageCountAll,
|
|
|
|
write: (iValue) => {
|
2021-07-22 22:24:24 +08:00
|
|
|
if (isPosNumeric(iValue)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
folder.privateMessageCountAll(iValue);
|
|
|
|
} else {
|
|
|
|
folder.privateMessageCountAll.valueHasMutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.extend({ notify: 'always' });
|
|
|
|
|
2021-12-31 20:30:05 +08:00
|
|
|
folder.messageCountUnread = koComputable({
|
2021-01-26 05:00:13 +08:00
|
|
|
read: folder.privateMessageCountUnread,
|
|
|
|
write: (value) => {
|
2021-07-22 22:24:24 +08:00
|
|
|
if (isPosNumeric(value)) {
|
2021-01-26 05:00:13 +08:00
|
|
|
folder.privateMessageCountUnread(value);
|
|
|
|
} else {
|
|
|
|
folder.privateMessageCountUnread.valueHasMutated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.extend({ notify: 'always' });
|
|
|
|
|
|
|
|
folder.addComputables({
|
|
|
|
|
|
|
|
isInbox: () => FolderType.Inbox === folder.type(),
|
|
|
|
|
2021-08-25 03:10:49 +08:00
|
|
|
isFlagged: () => FolderUserStore.currentFolder() === folder
|
2021-11-04 02:25:52 +08:00
|
|
|
&& MessageUserStore.listSearch().includes('flagged'),
|
2021-08-25 03:10:49 +08:00
|
|
|
|
2021-11-04 02:25:52 +08:00
|
|
|
hasVisibleSubfolders: () => !!folder.subFolders().find(folder => folder.visible()),
|
|
|
|
|
|
|
|
hasSubscriptions: () => folder.subscribed() | !!folder.subFolders().find(
|
2021-08-25 02:45:40 +08:00
|
|
|
oFolder => {
|
|
|
|
const subscribed = oFolder.hasSubscriptions();
|
|
|
|
return !oFolder.isSystemFolder() && subscribed;
|
|
|
|
}
|
|
|
|
),
|
2021-01-26 05:00:13 +08:00
|
|
|
|
2021-08-25 22:27:17 +08:00
|
|
|
canBeEdited: () => FolderType.User === folder.type() && folder.exists/* && folder.selectable()*/,
|
2021-01-26 05:00:13 +08:00
|
|
|
|
2021-10-26 21:43:27 +08:00
|
|
|
isSystemFolder: () => FolderType.User !== folder.type() | !!folder.kolabType(),
|
2021-01-26 05:00:13 +08:00
|
|
|
|
2021-11-04 02:25:52 +08:00
|
|
|
canBeSelected: () => folder.selectable() && !folder.isSystemFolder(),
|
|
|
|
|
|
|
|
canBeDeleted: () => folder.canBeSelected() && folder.exists,
|
|
|
|
|
|
|
|
canBeSubscribed: () => folder.selectable()
|
|
|
|
&& !(folder.isSystemFolder() | !SettingsUserStore.hideUnsubscribed()),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Folder is visible when:
|
|
|
|
* - hasVisibleSubfolders()
|
|
|
|
* Or when all below conditions are true:
|
|
|
|
* - selectable()
|
|
|
|
* - subscribed() OR hideUnsubscribed = false
|
|
|
|
* - FolderType.User
|
|
|
|
* - not kolabType()
|
|
|
|
*/
|
|
|
|
visible: () => {
|
|
|
|
const selectable = folder.canBeSelected(),
|
|
|
|
visible = (folder.subscribed() | !SettingsUserStore.hideUnsubscribed()) && selectable;
|
|
|
|
return folder.hasVisibleSubfolders() | visible;
|
2021-01-26 05:00:13 +08:00
|
|
|
},
|
|
|
|
|
2021-11-04 02:25:52 +08:00
|
|
|
hidden: () => !folder.selectable() && (folder.isSystemFolder() | !folder.hasVisibleSubfolders()),
|
|
|
|
|
2021-01-26 05:00:13 +08:00
|
|
|
printableUnreadCount: () => {
|
|
|
|
const count = folder.messageCountAll(),
|
|
|
|
unread = folder.messageCountUnread(),
|
|
|
|
type = folder.type();
|
|
|
|
|
2021-07-30 18:26:27 +08:00
|
|
|
if (count) {
|
2021-08-20 21:40:07 +08:00
|
|
|
if (FolderType.Drafts === type) {
|
2021-07-30 18:26:27 +08:00
|
|
|
return count;
|
2021-01-26 05:00:13 +08:00
|
|
|
}
|
|
|
|
if (
|
2021-07-30 18:26:27 +08:00
|
|
|
unread &&
|
2021-01-26 05:00:13 +08:00
|
|
|
FolderType.Trash !== type &&
|
|
|
|
FolderType.Archive !== type &&
|
2021-08-20 21:40:07 +08:00
|
|
|
FolderType.Sent !== type
|
2021-01-26 05:00:13 +08:00
|
|
|
) {
|
2021-07-30 18:26:27 +08:00
|
|
|
return unread;
|
2021-01-26 05:00:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-30 18:26:27 +08:00
|
|
|
return null;
|
2021-01-26 05:00:13 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
localName: () => {
|
|
|
|
let name = folder.name();
|
|
|
|
if (folder.isSystemFolder()) {
|
|
|
|
translatorTrigger();
|
|
|
|
name = getSystemFolderName(folder.type(), name);
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
},
|
|
|
|
|
|
|
|
manageFolderSystemName: () => {
|
|
|
|
if (folder.isSystemFolder()) {
|
|
|
|
translatorTrigger();
|
2021-10-21 23:15:00 +08:00
|
|
|
let suffix = getSystemFolderName(folder.type(), getKolabFolderName(folder.kolabType()));
|
2021-01-26 05:00:13 +08:00
|
|
|
if (folder.name() !== suffix && 'inbox' !== suffix.toLowerCase()) {
|
|
|
|
return '(' + suffix + ')';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
},
|
|
|
|
|
|
|
|
hasUnreadMessages: () => 0 < folder.messageCountUnread() && folder.printableUnreadCount(),
|
|
|
|
|
|
|
|
hasSubscribedUnreadMessagesSubfolders: () =>
|
2021-11-04 02:25:52 +08:00
|
|
|
!!folder.subFolders().find(
|
|
|
|
folder => folder.hasUnreadMessages() | folder.hasSubscribedUnreadMessagesSubfolders()
|
|
|
|
)
|
2021-12-08 18:06:42 +08:00
|
|
|
|
|
|
|
// ,href: () => folder.canBeSelected() && mailBox(folder.fullNameHash)
|
2021-01-26 05:00:13 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
folder.addSubscribables({
|
|
|
|
name: value => folder.nameForEdit(value),
|
|
|
|
|
|
|
|
edited: value => value && folder.nameForEdit(folder.name()),
|
|
|
|
|
|
|
|
messageCountUnread: unread => {
|
|
|
|
if (FolderType.Inbox === folder.type()) {
|
2022-02-11 19:21:16 +08:00
|
|
|
fireEvent('mailbox.inbox-unread-count', unread);
|
2021-01-26 05:00:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
collapsedCss() {
|
2021-11-04 02:25:52 +08:00
|
|
|
return 'e-collapsed-sign ' + (this.hasVisibleSubfolders()
|
2021-01-26 05:00:13 +08:00
|
|
|
? (this.collapsed() ? 'icon-right-mini' : 'icon-down-mini')
|
|
|
|
: 'icon-none'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|