This commit is contained in:
djmaze 2021-12-22 10:03:57 +01:00
parent 254ec34b8c
commit 0d31261063
3 changed files with 15 additions and 13 deletions

View file

@ -70,7 +70,7 @@ class THREAD extends Request
$aReturn = array(); $aReturn = array();
foreach ($this->oImapClient->yieldUntaggedResponses() as $oResponse) { foreach ($this->oImapClient->yieldUntaggedResponses() as $oResponse) {
$iOffset = ($bReturnUid && 'UID' === $oResponse->StatusOrIndex && !empty($oResponse->ResponseList[2]) && 'THREAD' === $oResponse->ResponseList[2]) ? 1 : 0; $iOffset = ($this->bUid && 'UID' === $oResponse->StatusOrIndex && !empty($oResponse->ResponseList[2]) && 'THREAD' === $oResponse->ResponseList[2]) ? 1 : 0;
if (('THREAD' === $oResponse->StatusOrIndex || $iOffset) if (('THREAD' === $oResponse->StatusOrIndex || $iOffset)
&& \is_array($oResponse->ResponseList) && \is_array($oResponse->ResponseList)
&& 2 < \count($oResponse->ResponseList)) && 2 < \count($oResponse->ResponseList))

View file

@ -1039,21 +1039,23 @@ class MailClient
$oMessageCollection->FolderName, $oMessageCollection->FolderHash, $bUseSortIfSupported, $oParams->sSort); $oMessageCollection->FolderName, $oMessageCollection->FolderHash, $bUseSortIfSupported, $oParams->sSort);
if ($bUseThreads) { if ($bUseThreads) {
$aAllThreads = $this->MessageListThreadsMap($oMessageCollection->FolderName, $oMessageCollection->FolderHash, $oParams->oCacher);
if (0 < $oParams->iThreadUid) if (0 < $oParams->iThreadUid)
{ {
$aAllThreads = $this->MessageListThreadsMap($oMessageCollection->FolderName, $oMessageCollection->FolderHash, $oParams->oCacher);
$aUids = [$oParams->iThreadUid]; $aUids = [$oParams->iThreadUid];
// Only show the selected thread messages // Only show the selected thread messages
foreach ($aAllThreads as $aMap) { foreach ($aAllThreads as $aMap) {
if (\in_array($oParams->iThreadUid, $aMap)) { if (\in_array($oParams->iThreadUid, $aMap)) {
$aUids = \array_intersect($aUids, $aMap); $aUids = $aMap;
break; break;
} }
} }
} }
else else
{ {
// $aUids = \array_diff($aUids, $aAllThreads); // Show all threads
// $aUids = array();
// \array_walk_recursive($aAllThreads, function($a) use (&$aUids) { $aUids[] = $a; });
} }
} }
@ -1155,17 +1157,16 @@ class MailClient
} }
} }
if ($bUseThreads && 0 === $oParams->iThreadUid && \count($aAllThreads)) if ($bUseThreads && !$oParams->iThreadUid && $aAllThreads)
{ {
foreach ($oMessageCollection as $oMessage) { foreach ($oMessageCollection as $oMessage) {
$iUid = $oMessage->Uid(); $iUid = $oMessage->Uid();
if (isset($aAllThreads[$iUid]) && \is_array($aAllThreads[$iUid]) && \count($aAllThreads[$iUid])) // Find thread
{ foreach ($aAllThreads as $aMap) {
$aSubThreads = $aAllThreads[$iUid]; if (\in_array($iUid, $aMap)) {
\array_unshift($aSubThreads, $iUid); $oMessage->SetThreads($aMap);
break;
$oMessage->SetThreads(\array_map('trim', $aSubThreads)); }
unset($aSubThreads);
} }
} }
} }

View file

@ -24,9 +24,10 @@ trait Messages
{ {
$this->verifyCacheByKey($sRawKey); $this->verifyCacheByKey($sRawKey);
// $oParams->sHash = (string) $aValues['Hash'];
$oParams->sFolderName = (string) $aValues['Folder']; $oParams->sFolderName = (string) $aValues['Folder'];
$oParams->iOffset = (int) $aValues['Offset'];
$oParams->iLimit = (int) $aValues['Limit']; $oParams->iLimit = (int) $aValues['Limit'];
$oParams->iOffset = (int) $aValues['Offset'];
$oParams->sSearch = (string) $aValues['Search']; $oParams->sSearch = (string) $aValues['Search'];
$oParams->sSort = (string) $aValues['Sort']; $oParams->sSort = (string) $aValues['Sort'];
if (isset($aValues['UidNext'])) { if (isset($aValues['UidNext'])) {