diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index e087b3c43..38ea52887 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -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'))) { diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index edf8af10c..42b56f9c3 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -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 diff --git a/snappymail/v/0.0.0/app/libraries/snappymail/shutdown.php b/snappymail/v/0.0.0/app/libraries/snappymail/shutdown.php index 6cc51b463..20ec357b8 100644 --- a/snappymail/v/0.0.0/app/libraries/snappymail/shutdown.php +++ b/snappymail/v/0.0.0/app/libraries/snappymail/shutdown.php @@ -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); + } }