mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Move folderInformation() function
This commit is contained in:
parent
88222034e6
commit
a18cc9a486
3 changed files with 61 additions and 54 deletions
|
|
@ -24,7 +24,6 @@ import {
|
|||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
|
||||
import {
|
||||
MessageFlagsCache,
|
||||
getFolderInboxName,
|
||||
getFolderFromCacheList
|
||||
} from 'Common/Cache';
|
||||
|
|
@ -60,11 +59,11 @@ import { FolderSystemPopupView } from 'View/Popup/FolderSystem';
|
|||
import { AskPopupView } from 'View/Popup/Ask';
|
||||
|
||||
import {
|
||||
folderInformation,
|
||||
folderInformationMultiply,
|
||||
refreshFoldersInterval,
|
||||
messagesMoveHelper,
|
||||
messagesDeleteHelper,
|
||||
fetchFolderInformation
|
||||
messagesDeleteHelper
|
||||
} from 'Common/Folders';
|
||||
import { loadFolders } from 'Model/FolderCollection';
|
||||
|
||||
|
|
@ -216,51 +215,7 @@ export class AppUser extends AbstractApp {
|
|||
* @param {Array=} list = []
|
||||
*/
|
||||
folderInformation(folder, list) {
|
||||
if (folder && folder.trim()) {
|
||||
fetchFolderInformation(
|
||||
(iError, data) => {
|
||||
if (!iError && data.Result) {
|
||||
const result = data.Result,
|
||||
folderFromCache = getFolderFromCacheList(result.Folder);
|
||||
if (folderFromCache) {
|
||||
const oldHash = folderFromCache.hash,
|
||||
unreadCountChange = (folderFromCache.unreadEmails() !== result.unreadEmails);
|
||||
|
||||
// folderFromCache.revivePropertiesFromJson(result);
|
||||
folderFromCache.expires = Date.now();
|
||||
folderFromCache.uidNext = result.UidNext;
|
||||
folderFromCache.hash = result.Hash;
|
||||
folderFromCache.totalEmails(result.totalEmails);
|
||||
folderFromCache.unreadEmails(result.unreadEmails);
|
||||
|
||||
if (unreadCountChange) {
|
||||
MessageFlagsCache.clearFolder(folderFromCache.fullName);
|
||||
}
|
||||
|
||||
if (result.MessagesFlags.length) {
|
||||
result.MessagesFlags.forEach(message =>
|
||||
MessageFlagsCache.setFor(folderFromCache.fullName, message.Uid.toString(), message.Flags)
|
||||
);
|
||||
|
||||
MessagelistUserStore.reloadFlagsAndCachedMessage();
|
||||
}
|
||||
|
||||
MessagelistUserStore.notifyNewMessages(folderFromCache.fullName, result.NewMessages);
|
||||
|
||||
if (!oldHash || unreadCountChange || result.Hash !== oldHash) {
|
||||
if (folderFromCache.fullName === FolderUserStore.currentFolderFullName()) {
|
||||
MessagelistUserStore.reload();
|
||||
} else if (getFolderInboxName() === folderFromCache.fullName) {
|
||||
Remote.messageList(null, {Folder: getFolderInboxName()}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
folder,
|
||||
list
|
||||
);
|
||||
}
|
||||
folderInformation(folder, list);
|
||||
}
|
||||
|
||||
logout() {
|
||||
|
|
@ -309,9 +264,9 @@ export class AppUser extends AbstractApp {
|
|||
setInterval(() => {
|
||||
const cF = FolderUserStore.currentFolderFullName(),
|
||||
iF = getFolderInboxName();
|
||||
this.folderInformation(iF);
|
||||
folderInformation(iF);
|
||||
if (iF !== cF) {
|
||||
this.folderInformation(cF);
|
||||
folderInformation(cF);
|
||||
}
|
||||
folderInformationMultiply();
|
||||
}, refreshFoldersInterval);
|
||||
|
|
@ -323,7 +278,7 @@ export class AppUser extends AbstractApp {
|
|||
setTimeout(() => {
|
||||
const cF = FolderUserStore.currentFolderFullName();
|
||||
if (getFolderInboxName() !== cF) {
|
||||
this.folderInformation(cF);
|
||||
folderInformation(cF);
|
||||
}
|
||||
FolderUserStore.hasCapability('LIST-STATUS') || folderInformationMultiply(true);
|
||||
}, 1000);
|
||||
|
|
|
|||
|
|
@ -129,6 +129,58 @@ folderListOptionsBuilder = (
|
|||
// Every 5 minutes
|
||||
refreshFoldersInterval = 300000,
|
||||
|
||||
/**
|
||||
* @param {string} folder
|
||||
* @param {Array=} list = []
|
||||
*/
|
||||
folderInformation = (folder, list) => {
|
||||
if (folder && folder.trim()) {
|
||||
fetchFolderInformation(
|
||||
(iError, data) => {
|
||||
if (!iError && data.Result) {
|
||||
const result = data.Result,
|
||||
folderFromCache = getFolderFromCacheList(result.Folder);
|
||||
if (folderFromCache) {
|
||||
const oldHash = folderFromCache.hash,
|
||||
unreadCountChange = (folderFromCache.unreadEmails() !== result.unreadEmails);
|
||||
|
||||
// folderFromCache.revivePropertiesFromJson(result);
|
||||
folderFromCache.expires = Date.now();
|
||||
folderFromCache.uidNext = result.UidNext;
|
||||
folderFromCache.hash = result.Hash;
|
||||
folderFromCache.totalEmails(result.totalEmails);
|
||||
folderFromCache.unreadEmails(result.unreadEmails);
|
||||
|
||||
if (unreadCountChange) {
|
||||
MessageFlagsCache.clearFolder(folderFromCache.fullName);
|
||||
}
|
||||
|
||||
if (result.MessagesFlags.length) {
|
||||
result.MessagesFlags.forEach(message =>
|
||||
MessageFlagsCache.setFor(folderFromCache.fullName, message.Uid.toString(), message.Flags)
|
||||
);
|
||||
|
||||
MessagelistUserStore.reloadFlagsAndCachedMessage();
|
||||
}
|
||||
|
||||
MessagelistUserStore.notifyNewMessages(folderFromCache.fullName, result.NewMessages);
|
||||
|
||||
if (!oldHash || unreadCountChange || result.Hash !== oldHash) {
|
||||
if (folderFromCache.fullName === FolderUserStore.currentFolderFullName()) {
|
||||
MessagelistUserStore.reload();
|
||||
} else if (getFolderInboxName() === folderFromCache.fullName) {
|
||||
Remote.messageList(null, {Folder: getFolderInboxName()}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
folder,
|
||||
list
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {boolean=} boot = false
|
||||
*/
|
||||
|
|
@ -162,7 +214,7 @@ folderInformationMultiply = (boot = false) => {
|
|||
} else if (unreadCountChange
|
||||
&& folder.fullName === FolderUserStore.currentFolderFullName()
|
||||
&& MessagelistUserStore.length) {
|
||||
rl.app.folderInformation(folder.fullName, MessagelistUserStore());
|
||||
folderInformation(folder.fullName, MessagelistUserStore());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import { encodeHtml, HtmlEditor, htmlToPlain } from 'Common/Html';
|
|||
import { koArrayWithDestroy } from 'External/ko';
|
||||
|
||||
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
|
||||
import { messagesDeleteHelper } from 'Common/Folders';
|
||||
import { folderInformation, messagesDeleteHelper } from 'Common/Folders';
|
||||
import { serverRequest } from 'Common/Links';
|
||||
import { i18n, getNotification, getUploadErrorDescByCode, timestampToString } from 'Common/Translator';
|
||||
import { MessageFlagsCache, setFolderHash } from 'Common/Cache';
|
||||
|
|
@ -77,7 +77,7 @@ const
|
|||
if (FolderUserStore.currentFolderFullName() === draftsFolder) {
|
||||
MessagelistUserStore.reload(true);
|
||||
} else {
|
||||
rl.app.folderInformation(draftsFolder);
|
||||
folderInformation(draftsFolder);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue