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();
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)
&& \is_array($oResponse->ResponseList)
&& 2 < \count($oResponse->ResponseList))

View file

@ -1039,21 +1039,23 @@ class MailClient
$oMessageCollection->FolderName, $oMessageCollection->FolderHash, $bUseSortIfSupported, $oParams->sSort);
if ($bUseThreads) {
$aAllThreads = $this->MessageListThreadsMap($oMessageCollection->FolderName, $oMessageCollection->FolderHash, $oParams->oCacher);
if (0 < $oParams->iThreadUid)
{
$aAllThreads = $this->MessageListThreadsMap($oMessageCollection->FolderName, $oMessageCollection->FolderHash, $oParams->oCacher);
$aUids = [$oParams->iThreadUid];
// Only show the selected thread messages
foreach ($aAllThreads as $aMap) {
if (\in_array($oParams->iThreadUid, $aMap)) {
$aUids = \array_intersect($aUids, $aMap);
$aUids = $aMap;
break;
}
}
}
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) {
$iUid = $oMessage->Uid();
if (isset($aAllThreads[$iUid]) && \is_array($aAllThreads[$iUid]) && \count($aAllThreads[$iUid]))
{
$aSubThreads = $aAllThreads[$iUid];
\array_unshift($aSubThreads, $iUid);
$oMessage->SetThreads(\array_map('trim', $aSubThreads));
unset($aSubThreads);
// Find thread
foreach ($aAllThreads as $aMap) {
if (\in_array($iUid, $aMap)) {
$oMessage->SetThreads($aMap);
break;
}
}
}
}

View file

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