mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-26 00:51:24 +08:00
parent
7baa7af929
commit
501b0daa09
3 changed files with 26 additions and 8 deletions
|
@ -407,7 +407,7 @@ class MailClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
protected function MessageListThreadsMap(MessageCollection $oMessageCollection, ?\MailSo\Cache\CacheClient $oCacher) : array
|
||||
protected function MessageListThreadsMap(MessageCollection $oMessageCollection, ?\MailSo\Cache\CacheClient $oCacher, bool $bBackground = false) : array
|
||||
{
|
||||
$sFolderName = $oMessageCollection->FolderName;
|
||||
|
||||
|
@ -435,6 +435,15 @@ class MailClient
|
|||
return $aSerializedUids['ThreadsUids'];
|
||||
}
|
||||
}
|
||||
// Idea to fetch all UID's in background
|
||||
else if (!$bBackground) {
|
||||
$this->logWrite('Set MessageListThreadsMap() as background task ("'.$sFolderName.'" / '.$sSearch.')');
|
||||
\SnappyMail\Shutdown::add(function($oMailClient, $oMessageCollection, $oCacher) {
|
||||
$oMessageCollection->FolderInfo->MESSAGES = 0;
|
||||
$oMailClient->MessageListThreadsMap($oMessageCollection, $oCacher, true);
|
||||
}, [$this, $oMessageCollection, $oCacher]);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
$this->oImapClient->FolderExamine($sFolderName);
|
||||
|
@ -706,10 +715,12 @@ class MailClient
|
|||
/*
|
||||
// TODO: Idea to fetch all UID's in background
|
||||
// Must know what is cached so needs more thought
|
||||
\SnappyMail\Shutdown::add(function($oMailClient, $oParams) {
|
||||
$oParams->bIgnoreLimit = true;
|
||||
$oMailClient->MessageList($oParams);
|
||||
}, [$this, $oParams]);
|
||||
if ($oParams->oCacher && !$oParams->iOffset && !$oParams->iThreadUid && !\strlen($sSearch)) {
|
||||
\SnappyMail\Shutdown::add(function($oMailClient, $oParams) {
|
||||
$oParams->bIgnoreLimit = true;
|
||||
$oMailClient->MessageList($oParams);
|
||||
}, [$this, $oParams]);
|
||||
}
|
||||
*/
|
||||
// if ((0 < $message_list_limit && $message_list_limit < $oInfo->MESSAGES)
|
||||
// || (!$this->oImapClient->hasCapability('SORT') && !$this->oImapClient->CapabilityValue('THREAD'))) {
|
||||
|
|
|
@ -241,13 +241,15 @@ class Actions
|
|||
|
||||
public function BootEnd(): void
|
||||
{
|
||||
/*
|
||||
try {
|
||||
if ($this->ImapClient()->IsLoggined()) {
|
||||
if (!\SnappyMail\Shutdown::count() && $this->ImapClient()->IsLoggined()) {
|
||||
$this->ImapClient()->Disconnect();
|
||||
}
|
||||
} catch (\Throwable $oException) {
|
||||
unset($oException);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected function compileLogParams(string $sLine, ?Model\Account $oAccount = null, array $aAdditionalParams = array()): string
|
||||
|
|
|
@ -8,7 +8,7 @@ abstract class Shutdown
|
|||
$actions = [],
|
||||
$running = false;
|
||||
|
||||
final public function run() : void
|
||||
final public static function run() : void
|
||||
{
|
||||
if (!static::$running && \count(static::$actions)) {
|
||||
static::$running = true;
|
||||
|
@ -35,11 +35,16 @@ abstract class Shutdown
|
|||
}
|
||||
}
|
||||
|
||||
final public function add(callable $function, array $args = []) : void
|
||||
final public static function add(callable $function, array $args = []) : void
|
||||
{
|
||||
if (!\count(static::$actions)) {
|
||||
\register_shutdown_function('\\SnappyMail\\Shutdown::run');
|
||||
}
|
||||
static::$actions[] = [$function, $args];
|
||||
}
|
||||
|
||||
final public static function count() : int
|
||||
{
|
||||
return \count(static::$actions);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue