Changed MessageListThreadsMap(MessageCollection...) to MessageListThreadsMap(FolderInformation...)

This commit is contained in:
the-djmaze 2024-03-25 10:44:25 +01:00
parent 93a4d5ba88
commit d0ee5325f4
2 changed files with 14 additions and 13 deletions

View file

@ -418,23 +418,23 @@ class MailClient
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\* * @throws \MailSo\Imap\Exceptions\*
*/ */
protected function MessageListThreadsMap(MessageCollection $oMessageCollection, ?\MailSo\Cache\CacheClient $oCacher, bool $bBackground = false) : array protected function MessageListThreadsMap(FolderInformation $oFolderInfo, ?\MailSo\Cache\CacheClient $oCacher, bool $bBackground = false) : array
{ {
$sFolderName = $oMessageCollection->FolderName; $sFolderName = $oFolderInfo->FullName;
$sSearch = 'ALL'; $sSearch = 'ALL';
/* /*
$iThreadLimit = $this->oImapClient->Settings->thread_limit; $iThreadLimit = $this->oImapClient->Settings->thread_limit;
if ($iThreadLimit && $iThreadLimit < $oMessageCollection->FolderInfo->MESSAGES) { if ($iThreadLimit && $iThreadLimit < $oFolderInfo->MESSAGES) {
$sSearch = ($oMessageCollection->FolderInfo->MESSAGES - $iThreadLimit) . ':*'; $sSearch = ($oFolderInfo->MESSAGES - $iThreadLimit) . ':*';
} }
*/ */
$sSerializedHashKey = null; $sSerializedHashKey = null;
if ($oCacher && $oCacher->IsInited()) { if ($oCacher && $oCacher->IsInited()) {
$sSerializedHashKey = $sSerializedHashKey =
"ThreadsMapSorted/{$sSearch}/{$oMessageCollection->FolderInfo->etag}"; "ThreadsMapSorted/{$sSearch}/{$oFolderInfo->etag}";
// "ThreadsMapSorted/{$sSearch}/{$iThreadLimit}/{$oMessageCollection->FolderInfo->etag}"; // "ThreadsMapSorted/{$sSearch}/{$iThreadLimit}/{$oFolderInfo->etag}";
$this->logWrite($sSerializedHashKey); $this->logWrite($sSerializedHashKey);
@ -450,10 +450,10 @@ class MailClient
// Idea to fetch all UID's in background // Idea to fetch all UID's in background
else if (!$bBackground) { else if (!$bBackground) {
$this->logWrite('Set MessageListThreadsMap() as background task ("'.$sFolderName.'" / '.$sSearch.')'); $this->logWrite('Set MessageListThreadsMap() as background task ("'.$sFolderName.'" / '.$sSearch.')');
\SnappyMail\Shutdown::add(function($oMailClient, $oMessageCollection, $oCacher) { \SnappyMail\Shutdown::add(function($oMailClient, $oFolderInfo, $oCacher) {
$oMessageCollection->FolderInfo->MESSAGES = 0; $oFolderInfo->MESSAGES = 0;
$oMailClient->MessageListThreadsMap($oMessageCollection, $oCacher, true); $oMailClient->MessageListThreadsMap($oFolderInfo, $oCacher, true);
}, [$this, $oMessageCollection, $oCacher]); }, [$this, $oFolderInfo, $oCacher]);
return []; return [];
} }
*/ */
@ -746,6 +746,7 @@ class MailClient
if (100 > $message_list_limit || $message_list_limit > $oInfo->MESSAGES) { if (100 > $message_list_limit || $message_list_limit > $oInfo->MESSAGES) {
$message_list_limit = 0; $message_list_limit = 0;
} }
// Idea to fetch all UID's in background // Idea to fetch all UID's in background
$oAllParams = clone $oParams; $oAllParams = clone $oParams;
$oAllParams->sSearch = ''; $oAllParams->sSearch = '';
@ -759,8 +760,7 @@ class MailClient
\SnappyMail\Shutdown::add(function($oMailClient, $oAllParams, $oInfo, $oMessageCollection) { \SnappyMail\Shutdown::add(function($oMailClient, $oAllParams, $oInfo, $oMessageCollection) {
$oMailClient->GetUids($oAllParams, $oInfo); $oMailClient->GetUids($oAllParams, $oInfo);
if ($oAllParams->bUseThreads) { if ($oAllParams->bUseThreads) {
$oMessageCollection->FolderInfo->MESSAGES = 0; $oMailClient->MessageListThreadsMap($oMessageCollection->FolderInfo, $oAllParams->oCacher, true);
$oMailClient->MessageListThreadsMap($oMessageCollection, $oAllParams->oCacher, true);
} }
}, [$this, $oAllParams, $oInfo, $oMessageCollection]); }, [$this, $oAllParams, $oInfo, $oMessageCollection]);
} }
@ -802,7 +802,7 @@ class MailClient
} }
if ($oParams->bUseThreads) { if ($oParams->bUseThreads) {
$aAllThreads = $this->MessageListThreadsMap($oMessageCollection, $oParams->oCacher); $aAllThreads = $this->MessageListThreadsMap($oMessageCollection->FolderInfo, $oParams->oCacher);
$oMessageCollection->totalThreads = \count($aAllThreads); $oMessageCollection->totalThreads = \count($aAllThreads);
// $iThreadLimit = $this->oImapClient->Settings->thread_limit; // $iThreadLimit = $this->oImapClient->Settings->thread_limit;
if ($oParams->iThreadUid) { if ($oParams->iThreadUid) {

View file

@ -64,6 +64,7 @@ class MessageListParams
$this->bSearchFuzzy ? '1' : '0', $this->bSearchFuzzy ? '1' : '0',
$this->bUseSort ? $this->sSort : '0', $this->bUseSort ? $this->sSort : '0',
$this->bUseThreads ? $this->iThreadUid : '', $this->bUseThreads ? $this->iThreadUid : '',
// $this->oSequenceSet ? $this->oSequenceSet : '',
$this->iPrevUidNext $this->iPrevUidNext
])); ]));
} }