Merge pull request #122 from Alphix/fix_issue_72

Fix issue #72
This commit is contained in:
the-djmaze 2021-08-25 12:02:51 +02:00 committed by GitHub
commit b1f78361f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 30 deletions

View file

@ -68,13 +68,15 @@ export class FolderCollectionModel extends AbstractCollectionModel
return super.reviveFromJson(object, oFolder => {
let oCacheFolder = Cache.getFolderFromCacheList(oFolder.FullNameRaw);
/*
if (oCacheFolder) {
oFolder.SubFolders = FolderCollectionModel.reviveFromJson(oFolder.SubFolders);
oFolder.SubFolders && oCacheFolder.subFolders(oFolder.SubFolders);
}
*/
if (!oCacheFolder && (oCacheFolder = FolderModel.reviveFromJson(oFolder))) {
} else {
oCacheFolder = FolderModel.reviveFromJson(oFolder);
if (!oCacheFolder)
return null;
if (1 == SystemFolders.indexOf(oFolder.FullNameRaw)) {
oCacheFolder.type(FolderType.Inbox);
Cache.setFolderInboxName(oFolder.FullNameRaw);
@ -82,7 +84,6 @@ export class FolderCollectionModel extends AbstractCollectionModel
Cache.setFolder(oCacheFolder.fullNameHash, oFolder.FullNameRaw, oCacheFolder);
}
if (oCacheFolder) {
let type = SystemFolders.indexOf(oFolder.FullNameRaw);
if (1 < type) {
oCacheFolder.type(type);
@ -105,7 +106,6 @@ export class FolderCollectionModel extends AbstractCollectionModel
oCacheFolder.messageCountUnread(oFolder.Extended.MessageUnseenCount);
}
}
}
return oCacheFolder;
});
}

View file

@ -2083,27 +2083,28 @@ class MailClient
*/
public function FolderCreate(string $sFolderNameInUtf8, string $sFolderParentFullNameRaw = '', bool $bSubscribeOnCreation = true, string $sDelimiter = '') : self
{
if (!strlen(\trim($sFolderNameInUtf8)))
$sFolderNameInUtf8 = \trim($sFolderNameInUtf8);
$sFolderParentFullNameRaw = \trim($sFolderParentFullNameRaw);
if (0 === \strlen($sFolderNameInUtf8))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException;
}
$sFolderNameInUtf8 = \trim($sFolderNameInUtf8);
if (0 === \strlen($sDelimiter) || 0 < \strlen(\trim($sFolderParentFullNameRaw)))
if (0 === \strlen($sDelimiter) || 0 < \strlen($sFolderParentFullNameRaw))
{
$aFolders = $this->oImapClient->FolderList('', 0 === \strlen(\trim($sFolderParentFullNameRaw)) ? 'INBOX' : $sFolderParentFullNameRaw);
$aFolders = $this->oImapClient->FolderList('', 0 === \strlen($sFolderParentFullNameRaw) ? 'INBOX' : $sFolderParentFullNameRaw);
if (!$aFolders)
{
// TODO
throw new \MailSo\Mail\Exceptions\RuntimeException(
0 === \strlen(trim($sFolderParentFullNameRaw))
0 === \strlen($sFolderParentFullNameRaw)
? 'Cannot get folder delimiter'
: 'Cannot create folder in non-existen parent folder');
}
$sDelimiter = $aFolders[0]->Delimiter();
if (0 < \strlen($sDelimiter) && 0 < \strlen(\trim($sFolderParentFullNameRaw)))
if (0 < \strlen($sDelimiter) && 0 < \strlen($sFolderParentFullNameRaw))
{
$sFolderParentFullNameRaw .= $sDelimiter;
}