mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 04:22:15 +08:00
Speedup generating folderlist
This commit is contained in:
parent
f992a06b63
commit
4d6d0622e5
5 changed files with 29 additions and 21 deletions
|
@ -297,7 +297,7 @@ export class FolderModel extends AbstractModel {
|
|||
|
||||
visible: () => folder.hasSubscriptions() | !SettingsUserStore.hideUnsubscribed(),
|
||||
|
||||
isSystemFolder: () => FolderType.User !== folder.type() || !!folder.kolabType(),
|
||||
isSystemFolder: () => FolderType.User !== folder.type() | !!folder.kolabType(),
|
||||
|
||||
hidden: () => {
|
||||
let hasSubFolders = folder.hasSubscribedSubfolders();
|
||||
|
@ -354,9 +354,7 @@ export class FolderModel extends AbstractModel {
|
|||
},
|
||||
|
||||
collapsed: {
|
||||
read: () => folder.isInbox() && FolderUserStore.singleRootFolder()
|
||||
? false
|
||||
: !folder.hidden() && folder.collapsedPrivate(),
|
||||
read: () => !folder.hidden() && folder.collapsedPrivate(),
|
||||
write: value => folder.collapsedPrivate(value)
|
||||
},
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ import { showScreenPopup } from 'Knoin/Knoin';
|
|||
import { FolderCreatePopupView } from 'View/Popup/FolderCreate';
|
||||
import { FolderSystemPopupView } from 'View/Popup/FolderSystem';
|
||||
|
||||
const folderForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
|
||||
export class FoldersUserSettings /*extends AbstractViewSettings*/ {
|
||||
constructor() {
|
||||
this.showKolab = Settings.capa(Capa.Kolab) && FolderUserStore.metadataSupported();
|
||||
|
@ -56,7 +58,7 @@ export class FoldersUserSettings /*extends AbstractViewSettings*/ {
|
|||
return loading || creating || deleting || renaming;
|
||||
});
|
||||
|
||||
this.folderForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
this.folderForDeletion = folderForDeletion;
|
||||
|
||||
this.folderForEdit = ko.observable(null).extend({ toggleSubscribeProperty: [this, 'edited'] });
|
||||
|
||||
|
@ -111,7 +113,7 @@ export class FoldersUserSettings /*extends AbstractViewSettings*/ {
|
|||
folderToRemove.deleteAccess() &&
|
||||
0 === folderToRemove.privateMessageCountAll()
|
||||
) {
|
||||
this.folderForDeletion(null);
|
||||
folderForDeletion(null);
|
||||
|
||||
if (folderToRemove) {
|
||||
Local.set(ClientSideKeyName.FoldersLashHash, '');
|
||||
|
@ -123,6 +125,7 @@ export class FoldersUserSettings /*extends AbstractViewSettings*/ {
|
|||
() => {
|
||||
folderToRemove.selectable(false)
|
||||
removeFolderFromCacheList(folderToRemove.fullNameRaw);
|
||||
FolderUserStore.folderList(FolderUserStore.folderList.filter(folder => folder !== folderToRemove));
|
||||
},
|
||||
error => {
|
||||
FolderUserStore.folderListError(
|
||||
|
|
|
@ -57,18 +57,6 @@ export const FolderUserStore = new class {
|
|||
|
||||
draftFolderNotEnabled: () => !this.draftFolder() || UNUSED_OPTION_VALUE === this.draftFolder(),
|
||||
|
||||
// foldersListWithSingleInboxRootFolder
|
||||
/** returns true when there are no non-system folders in the root of the folders tree */
|
||||
singleRootFolder: () => {
|
||||
let multiple = false;
|
||||
this.folderList.forEach(folder => {
|
||||
let subscribed = folder.subscribed(),
|
||||
hasSub = folder.hasSubscribedSubfolders();
|
||||
multiple |= (!folder.isSystemFolder() || (hasSub && !folder.isInbox())) && (subscribed || hasSub)
|
||||
});
|
||||
return !multiple;
|
||||
},
|
||||
|
||||
currentFolderFullNameRaw: () => (this.currentFolder() ? this.currentFolder().fullNameRaw : ''),
|
||||
|
||||
currentFolderFullName: () => (this.currentFolder() ? this.currentFolder().fullName : ''),
|
||||
|
|
|
@ -33,7 +33,7 @@ export class MailFolderList extends AbstractViewLeft {
|
|||
|
||||
this.moveAction = moveAction;
|
||||
|
||||
this.foldersListWithSingleInboxRootFolder = FolderUserStore.singleRootFolder;
|
||||
this.foldersListWithSingleInboxRootFolder = ko.observable(false);
|
||||
|
||||
this.leftPanelDisabled = leftPanelDisabled;
|
||||
|
||||
|
@ -42,7 +42,24 @@ export class MailFolderList extends AbstractViewLeft {
|
|||
addComputablesTo(this, {
|
||||
folderListFocused: () => Scope.FolderList === AppUserStore.focusedState(),
|
||||
|
||||
folderListVisible: () => FolderUserStore.folderList().filter(v => !(v.hidden() || v.kolabType()))
|
||||
folderListVisible: () => {
|
||||
let multiple = false,
|
||||
inbox, subscribed, hasSub,
|
||||
result = FolderUserStore.folderList().filter(folder => {
|
||||
if (folder.isInbox()) {
|
||||
inbox = folder;
|
||||
}
|
||||
subscribed = folder.subscribed();
|
||||
hasSub = folder.hasSubscribedSubfolders();
|
||||
multiple |= (!folder.isSystemFolder() || (hasSub && !folder.isInbox())) && (subscribed || hasSub)
|
||||
return !(folder.hidden() | folder.kolabType());
|
||||
});
|
||||
if (inbox && !multiple) {
|
||||
inbox.collapsedPrivate(false);
|
||||
}
|
||||
this.foldersListWithSingleInboxRootFolder(!multiple);
|
||||
return result;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<li data-bind="visible: visible">
|
||||
<!-- ko if: visible -->
|
||||
<li>
|
||||
<a data-bind="dropmessages: $data,
|
||||
css: { 'selected': selected() && !isSystemFolder(), 'system': isSystemFolder, 'selectable': canBeSelected, 'hidden' : hidden, 'unread-sub': hasSubscribedUnreadMessagesSubfolders, 'anim-action-class': actionBlink },
|
||||
attr: { 'data-unread': printableUnreadCount }">
|
||||
|
@ -9,3 +10,4 @@
|
|||
<ul data-bind="template: { name: 'MailFolderListItem', foreach: subFolders }, css: { 'collapsed': collapsed() }"></ul>
|
||||
<!-- /ko -->
|
||||
</li>
|
||||
<!-- /ko -->
|
||||
|
|
Loading…
Reference in a new issue