Rename Folder Hash to ETag as it is the more obvious name

This commit is contained in:
the-djmaze 2023-02-16 10:55:23 +01:00
parent 1a05a0adf2
commit fb2eb62f83
16 changed files with 74 additions and 69 deletions

View file

@ -34,28 +34,26 @@ export const
setFolderInboxName = name => inboxFolderName = name, setFolderInboxName = name => inboxFolderName = name,
/** /**
* @param {string} folderHash * @param {string} fullNameHash
* @returns {string} * @returns {string}
*/ */
getFolderFullName = folderHash => (folderHash && FOLDERS_NAME_CACHE[folderHash]) || '', getFolderFullName = fullNameHash => (fullNameHash && FOLDERS_NAME_CACHE[fullNameHash]) || '',
/** /**
* @param {string} folderHash
* @param {string} folderFullName
* @param {?FolderModel} folder * @param {?FolderModel} folder
*/ */
setFolder = folder => { setFolder = folder => {
folder.hash = ''; folder.etag = '';
FOLDERS_CACHE[folder.fullName] = folder; FOLDERS_CACHE[folder.fullName] = folder;
FOLDERS_NAME_CACHE[folder.fullNameHash] = folder.fullName; FOLDERS_NAME_CACHE[folder.fullNameHash] = folder.fullName;
}, },
/** /**
* @param {string} folderFullName * @param {string} folderFullName
* @param {string} folderHash * @param {string} folderETag
*/ */
setFolderHash = (folderFullName, folderHash) => setFolderETag = (folderFullName, folderETag) =>
FOLDERS_CACHE[folderFullName] && (FOLDERS_CACHE[folderFullName].hash = folderHash), FOLDERS_CACHE[folderFullName] && (FOLDERS_CACHE[folderFullName].etag = folderETag),
/** /**
* @param {string} folderFullName * @param {string} folderFullName

View file

@ -1,7 +1,7 @@
import { isArray, arrayLength } from 'Common/Utils'; import { isArray, arrayLength } from 'Common/Utils';
import { import {
MessageFlagsCache, MessageFlagsCache,
setFolderHash, setFolderETag,
getFolderInboxName, getFolderInboxName,
getFolderFromCacheList getFolderFromCacheList
} from 'Common/Cache'; } from 'Common/Cache';
@ -126,13 +126,13 @@ folderInformation = (folder, list) => {
const result = data.Result, const result = data.Result,
folderFromCache = getFolderFromCacheList(result.folder); folderFromCache = getFolderFromCacheList(result.folder);
if (folderFromCache) { if (folderFromCache) {
const oldHash = folderFromCache.hash, const oldHash = folderFromCache.etag,
unreadCountChange = (folderFromCache.unreadEmails() !== result.unreadEmails); unreadCountChange = (folderFromCache.unreadEmails() !== result.unreadEmails);
// folderFromCache.revivePropertiesFromJson(result); // folderFromCache.revivePropertiesFromJson(result);
folderFromCache.expires = Date.now(); folderFromCache.expires = Date.now();
folderFromCache.uidNext = result.uidNext; folderFromCache.uidNext = result.uidNext;
folderFromCache.hash = result.hash; folderFromCache.etag = result.etag;
folderFromCache.totalEmails(result.totalEmails); folderFromCache.totalEmails(result.totalEmails);
folderFromCache.unreadEmails(result.unreadEmails); folderFromCache.unreadEmails(result.unreadEmails);
@ -148,7 +148,7 @@ folderInformation = (folder, list) => {
MessagelistUserStore.notifyNewMessages(folderFromCache.fullName, result.newMessages); MessagelistUserStore.notifyNewMessages(folderFromCache.fullName, result.newMessages);
if (!oldHash || unreadCountChange || result.hash !== oldHash) { if (!oldHash || unreadCountChange || result.etag !== oldHash) {
if (folderFromCache.fullName === FolderUserStore.currentFolderFullName()) { if (folderFromCache.fullName === FolderUserStore.currentFolderFullName()) {
MessagelistUserStore.reload(); MessagelistUserStore.reload();
/* /*
@ -181,21 +181,21 @@ folderInformationMultiply = (boot = false) => {
if (!iError && arrayLength(oData.Result)) { if (!iError && arrayLength(oData.Result)) {
const utc = Date.now(); const utc = Date.now();
oData.Result.forEach(item => { oData.Result.forEach(item => {
const folder = getFolderFromCacheList(item.folder); const folder = getFolderFromCacheList(item.name);
if (folder) { if (folder) {
const oldHash = folder.hash, const oldHash = folder.etag,
unreadCountChange = folder.unreadEmails() !== item.unreadEmails; unreadCountChange = folder.unreadEmails() !== item.unreadEmails;
// folder.revivePropertiesFromJson(item); // folder.revivePropertiesFromJson(item);
folder.expires = utc; folder.expires = utc;
folder.hash = item.hash; folder.etag = item.etag;
folder.totalEmails(item.totalEmails); folder.totalEmails(item.totalEmails);
folder.unreadEmails(item.unreadEmails); folder.unreadEmails(item.unreadEmails);
unreadCountChange && MessageFlagsCache.clearFolder(folder.fullName); unreadCountChange && MessageFlagsCache.clearFolder(folder.fullName);
if (!oldHash || item.hash !== oldHash) { if (!oldHash || item.etag !== oldHash) {
if (folder.fullName === FolderUserStore.currentFolderFullName()) { if (folder.fullName === FolderUserStore.currentFolderFullName()) {
MessagelistUserStore.reload(); MessagelistUserStore.reload();
} }
@ -217,13 +217,13 @@ folderInformationMultiply = (boot = false) => {
moveOrDeleteResponseHelper = (iError, oData) => { moveOrDeleteResponseHelper = (iError, oData) => {
if (iError) { if (iError) {
setFolderHash(FolderUserStore.currentFolderFullName(), ''); setFolderETag(FolderUserStore.currentFolderFullName(), '');
alert(getNotification(iError)); alert(getNotification(iError));
} else if (FolderUserStore.currentFolder()) { } else if (FolderUserStore.currentFolder()) {
if (2 === arrayLength(oData.Result)) { if (2 === arrayLength(oData.Result)) {
setFolderHash(oData.Result[0], oData.Result[1]); setFolderETag(oData.Result[0], oData.Result[1]);
} else { } else {
setFolderHash(FolderUserStore.currentFolderFullName(), ''); setFolderETag(FolderUserStore.currentFolderFullName(), '');
} }
MessagelistUserStore.reload(!MessagelistUserStore.length); MessagelistUserStore.reload(!MessagelistUserStore.length);
} }

View file

@ -127,8 +127,8 @@ export class FolderCollectionModel extends AbstractCollectionModel
let oCacheFolder = getFolderFromCacheList(oFolder.fullName); let oCacheFolder = getFolderFromCacheList(oFolder.fullName);
if (oCacheFolder) { if (oCacheFolder) {
// oCacheFolder.revivePropertiesFromJson(oFolder); // oCacheFolder.revivePropertiesFromJson(oFolder);
if (oFolder.hash) { if (oFolder.etag) {
oCacheFolder.hash = oFolder.hash; oCacheFolder.etag = oFolder.etag;
} }
if (null != oFolder.totalEmails) { if (null != oFolder.totalEmails) {
oCacheFolder.totalEmails(oFolder.totalEmails); oCacheFolder.totalEmails(oFolder.totalEmails);
@ -300,7 +300,7 @@ export class FolderModel extends AbstractModel {
this.exists = true; this.exists = true;
this.hash = ''; this.etag = '';
this.id = 0; this.id = 0;
this.uidNext = 0; this.uidNext = 0;

View file

@ -13,17 +13,16 @@ export class MessageCollectionModel extends AbstractCollectionModel
/* /*
constructor() { constructor() {
super(); super();
this.Filtered this.filtered
this.folder this.folder
this.folderHash
this.folderInfo
this.totalEmails this.totalEmails
this.unreadEmails this.totalThreads
this.threadUid this.threadUid
this.newMessages this.newMessages
this.offset this.offset
this.limit this.limit
this.search this.search
this.limited
} }
*/ */

View file

@ -24,7 +24,7 @@ class RemoteUserFetch extends AbstractFetchRemote {
const const
// folder = getFolderFromCacheList(params.folder.fullName), // folder = getFolderFromCacheList(params.folder.fullName),
folder = getFolderFromCacheList(params.folder), folder = getFolderFromCacheList(params.folder),
folderHash = folder?.hash || ''; folderETag = folder?.etag || '';
params = Object.assign({ params = Object.assign({
offset: 0, offset: 0,
@ -40,8 +40,8 @@ class RemoteUserFetch extends AbstractFetchRemote {
} }
let sGetAdd = ''; let sGetAdd = '';
if (folderHash) { if (folderETag) {
params.hash = folderHash + '-' + SettingsGet('AccountHash'); params.hash = folderETag + '-' + SettingsGet('AccountHash');
sGetAdd = 'MessageList/' + SUB_QUERY_PREFIX + '/' + b64EncodeJSONSafe(params); sGetAdd = 'MessageList/' + SUB_QUERY_PREFIX + '/' + b64EncodeJSONSafe(params);
params = {}; params = {};
} }

View file

@ -10,7 +10,7 @@ import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { import {
getFolderInboxName, getFolderInboxName,
getFolderFromCacheList, getFolderFromCacheList,
setFolderHash, setFolderETag,
MessageFlagsCache MessageFlagsCache
} from 'Common/Cache'; } from 'Common/Cache';
@ -174,7 +174,7 @@ MessagelistUserStore.reload = (bDropPagePosition = false, bDropCurrentFolderCach
let iOffset = (MessagelistUserStore.page() - 1) * SettingsUserStore.messagesPerPage(); let iOffset = (MessagelistUserStore.page() - 1) * SettingsUserStore.messagesPerPage();
if (bDropCurrentFolderCache) { if (bDropCurrentFolderCache) {
setFolderHash(FolderUserStore.currentFolderFullName(), ''); setFolderETag(FolderUserStore.currentFolderFullName(), '');
} }
if (bDropPagePosition) { if (bDropPagePosition) {
@ -207,13 +207,14 @@ MessagelistUserStore.reload = (bDropPagePosition = false, bDropCurrentFolderCach
error = ''; error = '';
const const
folder = getFolderFromCacheList(collection.folder), folderInfo = collection.folder,
folderInfo = collection.folderInfo; folder = getFolderFromCacheList(folderInfo.name);
collection.folder = folderInfo.name;
if (folder && !bCached) { if (folder && !bCached) {
// folder.revivePropertiesFromJson(result); // folder.revivePropertiesFromJson(result);
folder.expires = Date.now(); folder.expires = Date.now();
folder.uidNext = folderInfo.uidNext; folder.uidNext = folderInfo.uidNext;
folder.hash = collection.folderHash; folder.etag = folderInfo.etag;
if (null != folderInfo.totalEmails) { if (null != folderInfo.totalEmails) {
folder.totalEmails(folderInfo.totalEmails); folder.totalEmails(folderInfo.totalEmails);
@ -251,14 +252,14 @@ MessagelistUserStore.reload = (bDropPagePosition = false, bDropCurrentFolderCach
MessagelistUserStore.threadUid(collection.threadUid); MessagelistUserStore.threadUid(collection.threadUid);
MessagelistUserStore.endHash( MessagelistUserStore.endHash(
collection.folder + folderInfo.name +
'|' + collection.search + '|' + collection.search +
'|' + MessagelistUserStore.threadUid() + '|' + MessagelistUserStore.threadUid() +
'|' + MessagelistUserStore.page() '|' + MessagelistUserStore.page()
); );
MessagelistUserStore.endThreadUid(collection.threadUid); MessagelistUserStore.endThreadUid(collection.threadUid);
const message = MessageUserStore.message(); const message = MessageUserStore.message();
if (message && collection.folder !== message.folder) { if (message && folderInfo.name !== message.folder) {
MessageUserStore.message(null); MessageUserStore.message(null);
} }
@ -370,7 +371,7 @@ MessagelistUserStore.removeMessagesFromList = (
messages.forEach(item => item?.isUnseen() && ++unseenCount); messages.forEach(item => item?.isUnseen() && ++unseenCount);
if (fromFolder) { if (fromFolder) {
fromFolder.hash = ''; fromFolder.etag = '';
if (!copy) { if (!copy) {
fromFolder.totalEmails( fromFolder.totalEmails(
0 <= fromFolder.totalEmails() - oUids.size ? fromFolder.totalEmails() - oUids.size : 0 0 <= fromFolder.totalEmails() - oUids.size ? fromFolder.totalEmails() - oUids.size : 0
@ -385,7 +386,7 @@ MessagelistUserStore.removeMessagesFromList = (
} }
if (toFolder) { if (toFolder) {
toFolder.hash = ''; toFolder.etag = '';
if (trashFolder === toFolder.fullName || spamFolder === toFolder.fullName) { if (trashFolder === toFolder.fullName || spamFolder === toFolder.fullName) {
unseenCount = 0; unseenCount = 0;

View file

@ -19,7 +19,7 @@ import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { folderInformation, messagesDeleteHelper } from 'Common/Folders'; import { folderInformation, messagesDeleteHelper } from 'Common/Folders';
import { serverRequest } from 'Common/Links'; import { serverRequest } from 'Common/Links';
import { i18n, getNotification, getUploadErrorDescByCode, timestampToString } from 'Common/Translator'; import { i18n, getNotification, getUploadErrorDescByCode, timestampToString } from 'Common/Translator';
import { MessageFlagsCache, setFolderHash } from 'Common/Cache'; import { MessageFlagsCache, setFolderETag } from 'Common/Cache';
import { Settings, SettingsCapa, SettingsGet, elementById, addShortcut, createElement } from 'Common/Globals'; import { Settings, SettingsCapa, SettingsGet, elementById, addShortcut, createElement } from 'Common/Globals';
//import { exitFullscreen, isFullscreen, toggleFullscreen } from 'Common/Fullscreen'; //import { exitFullscreen, isFullscreen, toggleFullscreen } from 'Common/Fullscreen';
@ -72,7 +72,7 @@ const
reloadDraftFolder = () => { reloadDraftFolder = () => {
const draftsFolder = FolderUserStore.draftsFolder(); const draftsFolder = FolderUserStore.draftsFolder();
if (draftsFolder && UNUSED_OPTION_VALUE !== draftsFolder) { if (draftsFolder && UNUSED_OPTION_VALUE !== draftsFolder) {
setFolderHash(draftsFolder, ''); setFolderETag(draftsFolder, '');
if (FolderUserStore.currentFolderFullName() === draftsFolder) { if (FolderUserStore.currentFolderFullName() === draftsFolder) {
MessagelistUserStore.reload(true); MessagelistUserStore.reload(true);
} else { } else {
@ -447,7 +447,7 @@ export class ComposePopupView extends AbstractViewPopup {
flagsCache.push(('forward' === this.aDraftInfo[0]) ? '$forwarded' : '\\answered'); flagsCache.push(('forward' === this.aDraftInfo[0]) ? '$forwarded' : '\\answered');
MessageFlagsCache.setFor(this.aDraftInfo[2], this.aDraftInfo[1], flagsCache); MessageFlagsCache.setFor(this.aDraftInfo[2], this.aDraftInfo[1], flagsCache);
MessagelistUserStore.reloadFlagsAndCachedMessage(); MessagelistUserStore.reloadFlagsAndCachedMessage();
setFolderHash(this.aDraftInfo[2], ''); setFolderETag(this.aDraftInfo[2], '');
} }
} }
@ -469,8 +469,8 @@ export class ComposePopupView extends AbstractViewPopup {
} else { } else {
this.close(); this.close();
} }
setFolderHash(this.draftsFolder(), ''); setFolderETag(this.draftsFolder(), '');
setFolderHash(sSentFolder, ''); setFolderETag(sSentFolder, '');
reloadDraftFolder(); reloadDraftFolder();
}, },
params, params,
@ -523,9 +523,9 @@ export class ComposePopupView extends AbstractViewPopup {
this.savedTime(new Date); this.savedTime(new Date);
if (this.bFromDraft) { if (this.bFromDraft) {
setFolderHash(this.draftsFolder(), ''); setFolderETag(this.draftsFolder(), '');
} }
setFolderHash(FolderUserStore.draftsFolder(), ''); setFolderETag(FolderUserStore.draftsFolder(), '');
} }
} }

View file

@ -3,7 +3,7 @@ import ko from 'ko';
import { Scope } from 'Common/Enums'; import { Scope } from 'Common/Enums';
import { addShortcut } from 'Common/Globals'; import { addShortcut } from 'Common/Globals';
import { mailBox, settings } from 'Common/Links'; import { mailBox, settings } from 'Common/Links';
//import { setFolderHash } from 'Common/Cache'; //import { setFolderETag } from 'Common/Cache';
import { addComputablesTo } from 'External/ko'; import { addComputablesTo } from 'External/ko';
import { AppUserStore } from 'Stores/User/App'; import { AppUserStore } from 'Stores/User/App';
@ -105,7 +105,7 @@ export class MailFolderList extends AbstractViewLeft {
} }
/* /*
if (folder.fullName === FolderUserStore.currentFolderFullName()) { if (folder.fullName === FolderUserStore.currentFolderFullName()) {
setFolderHash(folder.fullName, ''); setFolderETag(folder.fullName, '');
} }
*/ */
let search = ''; let search = '';

View file

@ -159,7 +159,7 @@ class Folder implements \JsonSerializable
public function Hash(string $sClientHash) : ?string public function Hash(string $sClientHash) : ?string
{ {
return $this->getHash($sClientHash); return $this->getETag($sClientHash);
} }
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
@ -172,7 +172,7 @@ class Folder implements \JsonSerializable
'totalEmails' => (int) $this->MESSAGES, 'totalEmails' => (int) $this->MESSAGES,
'unreadEmails' => (int) $this->UNSEEN, 'unreadEmails' => (int) $this->UNSEEN,
'uidNext' => (int) $this->UIDNEXT, 'uidNext' => (int) $this->UIDNEXT,
// 'hash' => $this->Hash($this->ImapClient()->Hash()) // 'etag' => $this->Hash($this->ImapClient()->Hash())
); );
} }
*/ */

View file

@ -19,6 +19,8 @@ class FolderInformation implements \JsonSerializable
{ {
use Traits\Status; use Traits\Status;
public string $etag = '';
public bool $IsWritable; public bool $IsWritable;
/** /**
@ -37,6 +39,11 @@ class FolderInformation implements \JsonSerializable
$this->IsWritable = $bIsWritable; $this->IsWritable = $bIsWritable;
} }
public function generateETag(ImapClient $oImapClient) : void
{
$this->etag = $this->getETag($oImapClient->Hash());
}
public function IsFlagSupported(string $sFlag) : bool public function IsFlagSupported(string $sFlag) : bool
{ {
return \in_array('\\*', $this->PermanentFlags) || return \in_array('\\*', $this->PermanentFlags) ||
@ -68,6 +75,9 @@ class FolderInformation implements \JsonSerializable
if (isset($this->SIZE)) { if (isset($this->SIZE)) {
$result['size'] = $this->SIZE; $result['size'] = $this->SIZE;
} }
if (isset($this->etag)) {
$result['etag'] = $this->etag;
}
return $result; return $result;
} }
} }

View file

@ -94,7 +94,7 @@ trait Status
*/ */
$SIZE; $SIZE;
public function getHash(string $sClientHash) : ?string public function getETag(string $sClientHash) : ?string
{ {
if (!isset($this->MESSAGES, $this->UIDNEXT)) { if (!isset($this->MESSAGES, $this->UIDNEXT)) {
return null; return null;

View file

@ -378,7 +378,7 @@ class MailClient
'mailboxId' => $oInfo->MAILBOXID ?: '', 'mailboxId' => $oInfo->MAILBOXID ?: '',
// 'flags' => $oInfo->Flags, // 'flags' => $oInfo->Flags,
// 'permanentFlags' => $oInfo->PermanentFlags, // 'permanentFlags' => $oInfo->PermanentFlags,
'hash' => $oInfo->getHash($this->oImapClient->Hash()), 'etag' => $oInfo->getETag($this->oImapClient->Hash()),
'messagesFlags' => $aFlags, 'messagesFlags' => $aFlags,
'newMessages' => $this->getFolderNextMessageInformation( 'newMessages' => $this->getFolderNextMessageInformation(
$sFolderName, $sFolderName,
@ -396,7 +396,8 @@ class MailClient
*/ */
public function FolderHash(string $sFolderName) : string public function FolderHash(string $sFolderName) : string
{ {
return $this->oImapClient->FolderStatus($sFolderName)->getHash($this->oImapClient->Hash()); return $this->oImapClient->FolderStatus($sFolderName)->getETag($this->oImapClient->Hash());
// return $this->oImapClient->FolderStatusAndSelect($sFolderName)->getETag($this->oImapClient->Hash());
} }
/** /**
@ -420,8 +421,8 @@ class MailClient
$sSerializedHashKey = null; $sSerializedHashKey = null;
if ($oCacher && $oCacher->IsInited()) { if ($oCacher && $oCacher->IsInited()) {
$sSerializedHashKey = $sSerializedHashKey =
"ThreadsMapSorted/{$sSearch}/{$sFolderName}/{$oMessageCollection->FolderHash}"; "ThreadsMapSorted/{$sSearch}/{$sFolderName}/{$oMessageCollection->FolderInfo->etag}";
// "ThreadsMapSorted/{$sSearch}/{$iThreadLimit}/{$sFolderName}/{$oMessageCollection->FolderHash}"; // "ThreadsMapSorted/{$sSearch}/{$iThreadLimit}/{$sFolderName}/{$oMessageCollection->FolderInfo->etag}";
if ($this->oLogger) { if ($this->oLogger) {
$this->oLogger->Write($sSerializedHashKey); $this->oLogger->Write($sSerializedHashKey);
@ -668,7 +669,7 @@ class MailClient
throw new \InvalidArgumentException('THREAD not supported'); throw new \InvalidArgumentException('THREAD not supported');
} }
$oMessageCollection->FolderHash = $oInfo->getHash($this->oImapClient->Hash()); $oInfo->generateETag($this->oImapClient);
if (!$oParams->iThreadUid) { if (!$oParams->iThreadUid) {
$oMessageCollection->NewMessages = $this->getFolderNextMessageInformation( $oMessageCollection->NewMessages = $this->getFolderNextMessageInformation(
@ -692,7 +693,7 @@ class MailClient
} }
if (\strlen($sSearch)) { if (\strlen($sSearch)) {
// Don't use SORT for speed // Don't use SORT for speed
$aUids = $this->GetUids($oParams, $sSearch, $oMessageCollection->FolderHash/*, $bUseSort*/); $aUids = $this->GetUids($oParams, $sSearch, $oInfo->etag/*, $bUseSort*/);
} else { } else {
$bUseSort = $this->oImapClient->hasCapability('SORT'); $bUseSort = $this->oImapClient->hasCapability('SORT');
if (2 > $oInfo->MESSAGES) { if (2 > $oInfo->MESSAGES) {
@ -702,7 +703,7 @@ class MailClient
$end = \min($oInfo->MESSAGES, \max(1, $oInfo->MESSAGES - $oParams->iOffset + $oParams->iLimit)); $end = \min($oInfo->MESSAGES, \max(1, $oInfo->MESSAGES - $oParams->iOffset + $oParams->iLimit));
$start = \max(1, $end - ($oParams->iLimit * 3) + 1); $start = \max(1, $end - ($oParams->iLimit * 3) + 1);
$oParams->oSequenceSet = new SequenceSet(\range($end, $start), false); $oParams->oSequenceSet = new SequenceSet(\range($end, $start), false);
$aRequestIndexes = $this->GetUids($oParams, '', $oMessageCollection->FolderHash, $bUseSort); $aRequestIndexes = $this->GetUids($oParams, '', $oInfo->etag, $bUseSort);
// Attempt to get the correct $oParams->iLimit slice // Attempt to get the correct $oParams->iLimit slice
$aRequestIndexes = \array_slice($aRequestIndexes, $oParams->iOffset ? $oParams->iLimit : 0, $oParams->iLimit); $aRequestIndexes = \array_slice($aRequestIndexes, $oParams->iOffset ? $oParams->iLimit : 0, $oParams->iLimit);
} else { } else {
@ -716,7 +717,7 @@ class MailClient
} else { } else {
$aUids = ($bUseThreads && $oParams->iThreadUid) $aUids = ($bUseThreads && $oParams->iThreadUid)
? [$oParams->iThreadUid] ? [$oParams->iThreadUid]
: $this->GetUids($oParams, '', $oMessageCollection->FolderHash, $bUseSort); : $this->GetUids($oParams, '', $oInfo->etag, $bUseSort);
if ($bUseThreads) { if ($bUseThreads) {
$aAllThreads = $this->MessageListThreadsMap($oMessageCollection, $oParams->oCacher); $aAllThreads = $this->MessageListThreadsMap($oMessageCollection, $oParams->oCacher);
@ -745,7 +746,7 @@ class MailClient
} }
if ($aUids && \strlen($sSearch)) { if ($aUids && \strlen($sSearch)) {
$aSearchedUids = $this->GetUids($oParams, $sSearch, $oMessageCollection->FolderHash/*, $bUseSort*/); $aSearchedUids = $this->GetUids($oParams, $sSearch, $oInfo->etag/*, $bUseSort*/);
if ($bUseThreads && !$oParams->iThreadUid) { if ($bUseThreads && !$oParams->iThreadUid) {
$matchingThreadUids = []; $matchingThreadUids = [];
foreach ($aAllThreads as $aMap) { foreach ($aAllThreads as $aMap) {

View file

@ -17,8 +17,6 @@ namespace MailSo\Mail;
*/ */
class MessageCollection extends \MailSo\Base\Collection class MessageCollection extends \MailSo\Base\Collection
{ {
public string $FolderHash = '';
/** /**
* Amount of UIDs in this list (could be less then total messages when using threads) * Amount of UIDs in this list (could be less then total messages when using threads)
*/ */
@ -62,16 +60,14 @@ class MessageCollection extends \MailSo\Base\Collection
return array_merge(parent::jsonSerialize(), array( return array_merge(parent::jsonSerialize(), array(
'totalEmails' => $this->totalEmails, 'totalEmails' => $this->totalEmails,
'totalThreads' => $this->totalThreads, 'totalThreads' => $this->totalThreads,
'folder' => $this->FolderName,
'folderHash' => $this->FolderHash,
'folderInfo' => $this->FolderInfo,
'threadUid' => $this->ThreadUid, 'threadUid' => $this->ThreadUid,
'newMessages' => $this->NewMessages, 'newMessages' => $this->NewMessages,
// 'filtered' => $this->Filtered, // 'filtered' => $this->Filtered,
'offset' => $this->Offset, 'offset' => $this->Offset,
'limit' => $this->Limit, 'limit' => $this->Limit,
'search' => $this->Search, 'search' => $this->Search,
'limited' => $this->Limited 'limited' => $this->Limited,
'folder' => $this->FolderInfo
)); ));
} }
} }

View file

@ -304,8 +304,8 @@ trait Folders
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder); $aInboxInformation = $this->MailClient()->FolderInformation($sFolder);
if (isset($aInboxInformation['folder'])) { if (isset($aInboxInformation['folder'])) {
$aResult[] = [ $aResult[] = [
'folder' => $aInboxInformation['folder'], 'name' => $aInboxInformation['folder'],
'hash' => $aInboxInformation['hash'], 'etag' => $aInboxInformation['etag'],
'totalEmails' => $aInboxInformation['totalEmails'], 'totalEmails' => $aInboxInformation['totalEmails'],
'unreadEmails' => $aInboxInformation['unreadEmails'], 'unreadEmails' => $aInboxInformation['unreadEmails'],
]; ];

View file

@ -65,7 +65,7 @@ trait Messages
// $oInfo = $this->MailClient()->FolderHash($oParams->sFolderName); // $oInfo = $this->MailClient()->FolderHash($oParams->sFolderName);
$oInfo = $this->ImapClient()->FolderStatusAndSelect($oParams->sFolderName); $oInfo = $this->ImapClient()->FolderStatusAndSelect($oParams->sFolderName);
$aRequestHash = \explode('-', $sHash); $aRequestHash = \explode('-', $sHash);
$sFolderHash = $oInfo->getHash($this->ImapClient()->Hash()); $sFolderHash = $oInfo->getETag($this->ImapClient()->Hash());
$sHash = $oParams->hash() . '-' . $sFolderHash; $sHash = $oParams->hash() . '-' . $sFolderHash;
if ($aRequestHash[1] == $sFolderHash) { if ($aRequestHash[1] == $sFolderHash) {
$this->verifyCacheByKey($sHash); $this->verifyCacheByKey($sHash);

View file

@ -193,7 +193,7 @@ trait Response
$sHash = $mResponse->Hash($this->ImapClient()->Hash()); $sHash = $mResponse->Hash($this->ImapClient()->Hash());
if ($sHash) { if ($sHash) {
$aResult['hash'] = $sHash; $aResult['etag'] = $sHash;
} }
if (null === $this->aCheckableFolder) { if (null === $this->aCheckableFolder) {