mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 00:47:04 +03:00
Improve folderInformation and folderInformationMultiply
This commit is contained in:
parent
a3dc8ad639
commit
26015aaf18
3 changed files with 41 additions and 59 deletions
|
|
@ -536,59 +536,46 @@ class AppUser extends AbstractApp {
|
||||||
if (folder && folder.trim()) {
|
if (folder && folder.trim()) {
|
||||||
Remote.folderInformation(
|
Remote.folderInformation(
|
||||||
(iError, data) => {
|
(iError, data) => {
|
||||||
if (!iError && data.Result.Hash && data.Result.Folder) {
|
if (!iError && data.Result) {
|
||||||
let check = false,
|
const result = data.Result,
|
||||||
unreadCountChange = false;
|
hash = getFolderHash(result.Folder),
|
||||||
|
folderFromCache = getFolderFromCacheList(result.Folder);
|
||||||
const folderFromCache = getFolderFromCacheList(data.Result.Folder);
|
|
||||||
if (folderFromCache) {
|
if (folderFromCache) {
|
||||||
folderFromCache.expires = Date.now();
|
folderFromCache.expires = Date.now();
|
||||||
|
|
||||||
if (data.Result.Hash) {
|
setFolderHash(result.Folder, result.Hash);
|
||||||
setFolderHash(data.Result.Folder, data.Result.Hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null != data.Result.MessageCount) {
|
folderFromCache.messageCountAll(result.MessageCount);
|
||||||
folderFromCache.messageCountAll(data.Result.MessageCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null != data.Result.MessageUnseenCount) {
|
let unreadCountChange = (folderFromCache.messageCountUnread() !== result.MessageUnseenCount);
|
||||||
if (pInt(folderFromCache.messageCountUnread()) !== pInt(data.Result.MessageUnseenCount)) {
|
|
||||||
unreadCountChange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
folderFromCache.messageCountUnread(data.Result.MessageUnseenCount);
|
folderFromCache.messageCountUnread(result.MessageUnseenCount);
|
||||||
}
|
|
||||||
|
|
||||||
if (unreadCountChange) {
|
if (unreadCountChange) {
|
||||||
MessageFlagsCache.clearFolder(folderFromCache.fullNameRaw);
|
MessageFlagsCache.clearFolder(folderFromCache.fullNameRaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.Result.Flags) {
|
if (result.Flags.length) {
|
||||||
Object.entries(data.Result.Flags).forEach(([uid,flags]) => {
|
result.Flags.forEach(flags =>
|
||||||
check = true;
|
MessageFlagsCache.storeByFolderAndUid(folderFromCache.fullNameRaw, flags.Uid.toString(), [
|
||||||
MessageFlagsCache.storeByFolderAndUid(folderFromCache.fullNameRaw, uid.toString(), [
|
|
||||||
!!flags.IsUnseen,
|
!!flags.IsUnseen,
|
||||||
!!flags.IsFlagged,
|
!!flags.IsFlagged,
|
||||||
!!flags.IsAnswered,
|
!!flags.IsAnswered,
|
||||||
!!flags.IsForwarded,
|
!!flags.IsForwarded,
|
||||||
!!flags.IsReadReceipt
|
!!flags.IsReadReceipt
|
||||||
]);
|
])
|
||||||
});
|
);
|
||||||
|
|
||||||
if (check) {
|
this.reloadFlagsCurrentMessageListAndMessageFromCache();
|
||||||
this.reloadFlagsCurrentMessageListAndMessageFromCache();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageUserStore.initUidNextAndNewMessages(
|
MessageUserStore.initUidNextAndNewMessages(
|
||||||
folderFromCache.fullNameRaw,
|
folderFromCache.fullNameRaw,
|
||||||
data.Result.UidNext,
|
result.UidNext,
|
||||||
data.Result.NewMessages
|
result.NewMessages
|
||||||
);
|
);
|
||||||
|
|
||||||
const hash = getFolderHash(data.Result.Folder);
|
if (!hash || unreadCountChange || result.Hash !== hash) {
|
||||||
if (!hash || unreadCountChange || data.Result.Hash !== hash) {
|
|
||||||
if (folderFromCache.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()) {
|
if (folderFromCache.fullNameRaw === FolderUserStore.currentFolderFullNameRaw()) {
|
||||||
this.reloadMessageList();
|
this.reloadMessageList();
|
||||||
} else if (getFolderInboxName() === folderFromCache.fullNameRaw) {
|
} else if (getFolderInboxName() === folderFromCache.fullNameRaw) {
|
||||||
|
|
@ -616,26 +603,17 @@ class AppUser extends AbstractApp {
|
||||||
oData.Result.List.forEach(item => {
|
oData.Result.List.forEach(item => {
|
||||||
const hash = getFolderHash(item.Folder),
|
const hash = getFolderHash(item.Folder),
|
||||||
folder = getFolderFromCacheList(item.Folder);
|
folder = getFolderFromCacheList(item.Folder);
|
||||||
let unreadCountChange = false;
|
|
||||||
|
|
||||||
if (folder) {
|
if (folder) {
|
||||||
folder.expires = utc;
|
folder.expires = utc;
|
||||||
|
|
||||||
if (item.Hash) {
|
setFolderHash(item.Folder, item.Hash);
|
||||||
setFolderHash(item.Folder, item.Hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null != item.MessageCount) {
|
folder.messageCountAll(item.MessageCount);
|
||||||
folder.messageCountAll(item.MessageCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null != item.MessageUnseenCount) {
|
let unreadCountChange = folder.messageCountUnread() !== item.MessageUnseenCount;
|
||||||
if (pInt(folder.messageCountUnread()) !== pInt(item.MessageUnseenCount)) {
|
|
||||||
unreadCountChange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
folder.messageCountUnread(item.MessageUnseenCount);
|
folder.messageCountUnread(item.MessageUnseenCount);
|
||||||
}
|
|
||||||
|
|
||||||
if (unreadCountChange) {
|
if (unreadCountChange) {
|
||||||
MessageFlagsCache.clearFolder(folder.fullNameRaw);
|
MessageFlagsCache.clearFolder(folder.fullNameRaw);
|
||||||
|
|
|
||||||
|
|
@ -705,7 +705,7 @@ class MailClient
|
||||||
'Hash' => $this->GenerateFolderHash($sFolderName, $iCount, $iUnseenCount, $sUidNext, $sHighestModSeq),
|
'Hash' => $this->GenerateFolderHash($sFolderName, $iCount, $iUnseenCount, $sUidNext, $sHighestModSeq),
|
||||||
'MessageCount' => $iCount,
|
'MessageCount' => $iCount,
|
||||||
'MessageUnseenCount' => $iUnseenCount,
|
'MessageUnseenCount' => $iUnseenCount,
|
||||||
'UidNext' => $sUidNext,
|
'UidNext' => (int) $sUidNext,
|
||||||
'Flags' => $aFlags,
|
'Flags' => $aFlags,
|
||||||
'HighestModSeq' => $sHighestModSeq,
|
'HighestModSeq' => $sHighestModSeq,
|
||||||
'NewMessages' => 'INBOX' === $sFolderName && \MailSo\Config::$CheckNewMessages ?
|
'NewMessages' => 'INBOX' === $sFolderName && \MailSo\Config::$CheckNewMessages ?
|
||||||
|
|
|
||||||
|
|
@ -357,22 +357,21 @@ trait Folders
|
||||||
$sFolder, $sPrevUidNext, $aFlagsFilteredUids
|
$sFolder, $sPrevUidNext, $aFlagsFilteredUids
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($aInboxInformation['Flags']) && \is_array($aInboxInformation['Flags']))
|
foreach ($aInboxInformation['Flags'] as $iUid => $aFlags)
|
||||||
{
|
{
|
||||||
foreach ($aInboxInformation['Flags'] as $iUid => $aFlags)
|
$aLowerFlags = \array_map('strtolower', $aFlags);
|
||||||
{
|
$aInboxInformation['Flags'][$iUid] = array(
|
||||||
$aLowerFlags = array_map('strtolower', $aFlags);
|
'Uid' => $iUid,
|
||||||
$aInboxInformation['Flags'][$iUid] = array(
|
'IsUnseen' => \in_array('\\unseen', $aLowerFlags) || !\in_array('\\seen', $aLowerFlags),
|
||||||
'IsUnseen' => \in_array('\\unseen', $aLowerFlags) || !\in_array('\\seen', $aLowerFlags),
|
'IsSeen' => \in_array('\\seen', $aLowerFlags),
|
||||||
'IsSeen' => in_array('\\seen', $aLowerFlags),
|
'IsFlagged' => \in_array('\\flagged', $aLowerFlags),
|
||||||
'IsFlagged' => in_array('\\flagged', $aLowerFlags),
|
'IsAnswered' => \in_array('\\answered', $aLowerFlags),
|
||||||
'IsAnswered' => in_array('\\answered', $aLowerFlags),
|
'IsDeleted' => \in_array('\\deleted', $aLowerFlags),
|
||||||
'IsDeleted' => in_array('\\deleted', $aLowerFlags),
|
'IsForwarded' => $sForwardedFlag && \in_array(\strtolower($sForwardedFlag), $aLowerFlags),
|
||||||
'IsForwarded' => 0 < strlen($sForwardedFlag) && in_array(strtolower($sForwardedFlag), $aLowerFlags),
|
'IsReadReceipt' => $sReadReceiptFlag && \in_array(\strtolower($sReadReceiptFlag), $aLowerFlags)
|
||||||
'IsReadReceipt' => 0 < strlen($sReadReceiptFlag) && in_array(strtolower($sReadReceiptFlag), $aLowerFlags)
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$aInboxInformation['Flags'] = \array_values($aInboxInformation['Flags']);
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
{
|
{
|
||||||
|
|
@ -409,7 +408,12 @@ trait Folders
|
||||||
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder, '', array());
|
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder, '', array());
|
||||||
if (isset($aInboxInformation['Folder']))
|
if (isset($aInboxInformation['Folder']))
|
||||||
{
|
{
|
||||||
$aResult['List'][] = $aInboxInformation;
|
$aResult['List'][] = [
|
||||||
|
'Folder' => $aInboxInformation['Folder'],
|
||||||
|
'Hash' => $aInboxInformation['Hash'],
|
||||||
|
'MessageCount' => $aInboxInformation['MessageCount'],
|
||||||
|
'MessageUnseenCount' => $aInboxInformation['MessageUnseenCount'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (\Throwable $oException)
|
catch (\Throwable $oException)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue