New thread list logic (step 2)

This commit is contained in:
RainLoop Team 2015-04-21 02:39:14 +04:00
parent b656b6365b
commit 03d26bc4c6
18 changed files with 139 additions and 517 deletions

View file

@ -1916,6 +1916,7 @@ class MailClient
* @param string $sSearch
* @param string $sFolderName
* @param string $sFolderHash
* @param bool $bUseSortIfSupported = false
*
* @return array
*
@ -1923,7 +1924,7 @@ class MailClient
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function GetUids($oCacher, $sSearch, $sFolderName, $sFolderHash)
public function GetUids($oCacher, $sSearch, $sFolderName, $sFolderHash, $bUseSortIfSupported = false)
{
$aResultUids = false;
$bUidsFromCacher = false;
@ -1932,7 +1933,7 @@ class MailClient
$sSerializedHash = '';
$sSerializedLog = '';
$bUseSortIfSupported = !!$this->oImapClient->IsSupported('SORT');
$bUseSortIfSupported = $bUseSortIfSupported ? !!$this->oImapClient->IsSupported('SORT') : false;
if (0 < \strlen($sSearch))
{
@ -2078,7 +2079,11 @@ class MailClient
if (0 < $iMessageRealCount)
{
$mAllSortedUids = $this->GetUids($oCacher, '', $oMessageCollection->FolderName, $oMessageCollection->FolderHash);
$mAllSortedUids = $this->GetUids($oCacher, '', $oMessageCollection->FolderName, $oMessageCollection->FolderHash, $bUseSortIfSupported);
$bUseSortIfSupported = $bUseSortIfSupported ? $this->oImapClient->IsSupported('SORT') : false;
// $bUseThreadSortIfSupported = $bUseThreadSortIfSupported ?
$mAllThreads = $bUseThreadSortIfSupported ? $this->MessageListThreadsMap(
$oMessageCollection->FolderName, $oMessageCollection->FolderHash, $mAllSortedUids, $oCacher) : null;

View file

@ -5455,45 +5455,6 @@ class Actions
return $this->DefaultResponse(__FUNCTION__, $aResult);
}
/**
* @return array
*
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoMessageThreadsFromCache()
{
$sFolder = $this->GetActionParam('Folder', '');
$sFolderHash = $this->GetActionParam('FolderHash', '');
$sUid = (string) $this->GetActionParam('Uid', '');
if (0 === \strlen($sFolder) || 0 === \strlen($sUid))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::InvalidInputArgument);
}
$aResult = array(
'Folder' => $sFolder,
'Uid' => $sUid,
'FolderHash' => $sFolderHash,
'ThreadUids' => null
);
$oCache = $this->cacherForUids();
if ($oCache && $this->Config()->Get('labs', 'use_imap_thread', false))
{
$aThreadUids = $this->MailClient()->MessageThreadUidsFromCache(
$sFolder, $sFolderHash, $sUid, $oCache
);
if (\is_array($aThreadUids) && 1 < \count($aThreadUids))
{
$aResult['ThreadUids'] = $aThreadUids;
}
}
return $this->DefaultResponse(__FUNCTION__, $aResult);
}
/**
* @return array
*
@ -5501,7 +5462,7 @@ class Actions
*/
public function DoMessageList()
{
// \sleep(1);
\sleep(1);
// throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList);
$sFolder = '';
@ -5581,40 +5542,6 @@ class Actions
return $this->DefaultResponse(__FUNCTION__, $oMessageList);
}
/**
* @return array
*
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoMessageListSimple()
{
// \sleep(2);
// throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList);
$sFolder = $this->GetActionParam('Folder', '');
$aUids = $this->GetActionParam('Uids', null);
if (0 === \strlen($sFolder) || !\is_array($aUids))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::InvalidInputArgument);
}
$this->initMailClientConnection();
$aMessageList = array();
try
{
$aMessageList = $this->MailClient()->MessageListSimple($sFolder, $aUids);
}
catch (\Exception $oException)
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList, $oException);
}
return $this->DefaultResponse(__FUNCTION__, $aMessageList);
}
/**
* @param \RainLoop\Model\Account $oAccount
* @param bool $bWithDraftInfo = true