mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
[snappymail] Rework FolderCollectionModel .js a bit
Following the previous bugfix, rework the .js code a bit to reduce the amount of nested ifdeffery.
This commit is contained in:
parent
0190170edd
commit
17f107057a
1 changed files with 21 additions and 21 deletions
|
|
@ -72,9 +72,11 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
||||||
if (oCacheFolder) {
|
if (oCacheFolder) {
|
||||||
oFolder.SubFolders = FolderCollectionModel.reviveFromJson(oFolder.SubFolders);
|
oFolder.SubFolders = FolderCollectionModel.reviveFromJson(oFolder.SubFolders);
|
||||||
oFolder.SubFolders && oCacheFolder.subFolders(oFolder.SubFolders);
|
oFolder.SubFolders && oCacheFolder.subFolders(oFolder.SubFolders);
|
||||||
}
|
} else {
|
||||||
|
oCacheFolder = FolderModel.reviveFromJson(oFolder);
|
||||||
|
if (!oCacheFolder)
|
||||||
|
return null;
|
||||||
|
|
||||||
if (!oCacheFolder && (oCacheFolder = FolderModel.reviveFromJson(oFolder))) {
|
|
||||||
if (1 == SystemFolders.indexOf(oFolder.FullNameRaw)) {
|
if (1 == SystemFolders.indexOf(oFolder.FullNameRaw)) {
|
||||||
oCacheFolder.type(FolderType.Inbox);
|
oCacheFolder.type(FolderType.Inbox);
|
||||||
Cache.setFolderInboxName(oFolder.FullNameRaw);
|
Cache.setFolderInboxName(oFolder.FullNameRaw);
|
||||||
|
|
@ -82,28 +84,26 @@ export class FolderCollectionModel extends AbstractCollectionModel
|
||||||
Cache.setFolder(oCacheFolder.fullNameHash, oFolder.FullNameRaw, oCacheFolder);
|
Cache.setFolder(oCacheFolder.fullNameHash, oFolder.FullNameRaw, oCacheFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oCacheFolder) {
|
let type = SystemFolders.indexOf(oFolder.FullNameRaw);
|
||||||
let type = SystemFolders.indexOf(oFolder.FullNameRaw);
|
if (1 < type) {
|
||||||
if (1 < type) {
|
oCacheFolder.type(type);
|
||||||
oCacheFolder.type(type);
|
}
|
||||||
|
|
||||||
|
oCacheFolder.collapsed(!expandedFolders
|
||||||
|
|| !isArray(expandedFolders)
|
||||||
|
|| !expandedFolders.includes(oCacheFolder.fullNameHash));
|
||||||
|
|
||||||
|
if (oFolder.Extended) {
|
||||||
|
if (oFolder.Extended.Hash) {
|
||||||
|
Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
oCacheFolder.collapsed(!expandedFolders
|
if (null != oFolder.Extended.MessageCount) {
|
||||||
|| !isArray(expandedFolders)
|
oCacheFolder.messageCountAll(oFolder.Extended.MessageCount);
|
||||||
|| !expandedFolders.includes(oCacheFolder.fullNameHash));
|
}
|
||||||
|
|
||||||
if (oFolder.Extended) {
|
if (null != oFolder.Extended.MessageUnseenCount) {
|
||||||
if (oFolder.Extended.Hash) {
|
oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount);
|
||||||
Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null != oFolder.Extended.MessageCount) {
|
|
||||||
oCacheFolder.messageCountAll(oFolder.Extended.MessageCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null != oFolder.Extended.MessageUnseenCount) {
|
|
||||||
oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return oCacheFolder;
|
return oCacheFolder;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue